Skip to content

Upgrading from 0.2 to 0.3

Pete Bacon Darwin edited this page May 2, 2014 · 3 revisions

Dgeni API

The main entry point to Dgeni has been tidied up. The main module has separate properties for each of the public entities that it provides. The module looks like:

module.exports = {
  log: require('winston'),
  Config: require('./config').Config,
  loadConfig: require('./config').load,
  generator: require('./doc-generator')
};

Doc Generator

Before you would do:

var docGenerator = require('dgeni');
var generateDocs = docGenerator('dgeni.conf.js');
generateDocs();

Now you should do:

var dgeni = require('dgeni');
var generateDocs = dgeni.generator('dgeni.conf.js');
generateDocs();

Config

The objects used to configure Dgeni must now be instances of Config, which can be accessed through:

var Config = require('dgeni').Config;
var config = new Config(...);

There is also a useful config loading tool if you want to load a config from a file:

var loadConfig = require('dgeni').loadConfig;
var config = loadConfig('dgeni.conf.js');

Usually you don't need to do this since the Dgeni generator can accept a string filename and do the loading for you.

Processors

The init(config, injectables) method is deprecated. Instead you can:

  • Inject config directly into your process method and get the configuration values you need there.

    process: function(docs, config) { ... }
    
  • Provide "injectables" through the new exports property on processors:

    exports: { someService: ['factory', function(dependencies) {
      ...
      return someServiceInstance;
    }
    

    These exports can also have dependencies, such as config injected in them too.

Utilities

The utility modules (i.e. require('dgeni/lib/utils');) have been removed from Dgeni as they are not used directly by the tool.

Some have been moved to the dgeni-packages project since that is where they are needed. If you were relying on such a module then you may be able to get them from require('dgeni-packages/utils');. But othewise you may need to look into the Dgeni history and take a copy of any file that you need for your own purposes.

Clone this wiki locally