angular / dgeni

Flexible JavaScript documentation generator used by AngularJS, Protractor and other JS projects
MIT License
767 stars 70 forks source link

Pipeline sequencing issue #119

Open daden opened 9 years ago

daden commented 9 years ago

I'd corresponding directly with Pete a couple of weeks ago when I started working with Dgeni about the pipeline sequence configuration living inside processor definitions. He explained the history and reasoning behind it which was understandable but as I continue to work with Dgeni, I'm becoming more convinced that using $runBefore and $runAfter properties inside processors to sequence them is a problem.

It puts configuration data inside code and hides the pipeline sequence in multiple files, each of which needs to be examined to find out what the sequence actually is.

But, I just found another potential issue -- I'm working with the markdown example and there are two processors that share the same $runBefore and $runAfter properties ('writing-files' and 'files-written' respectively) -- "writeFilesProcessor" and "checkAnchorLinksProcessor".

I got curious how the actual run order was determined and it appears it is based on the order in which the processors are defined in the relevant index.js. They are currently in this order:

.processor(require('./processors/write-files'))
(other .processor() calls here)
.processor(require('./processors/checkAnchorLinks'))

but if checkAnchorLinks is put above write-files, then the processors execute in the wrong order which makes it potentially even more confusing to know what will fire when.

Just wondering if others are running into problems with pipeline sequence data inside processor definitions or if this is something that goes away as a concern as you get more familiar with Dgeni.

forresst commented 9 years ago

Hi @daden,

There is a way to specify the order of the processors. For example in the ngdoc package, 3 processors are executed between "ids-computed" and "computing-paths". The correct order is:

  1. "ids-computed"
  2. memberDocsProcessor (see code)
  3. moduleDocsProcessor (see code)
  4. generateComponentGroupsProcessor (see code)
  5. "computing-paths"

In the definition of memberDocsProcessor, there must be the following:

$runAfter: ['ids-computed'],
$runBefore: ['computing-paths'],

In the definition of moduleDocsProcessor, there must be the following (Note, you must specify the processor memberDocsProcessor) :

$ runAfter: ['ids-computed', 'memberDocsProcessor'],
$ runBefore: ['computing-paths'],

In the definition of generateComponentGroupsProcessor, there must be the following (Note, you must specify the processor moduleDocsProcessor) :

$ runAfter: ['moduleDocsProcessor'],
$ runBefore: ['computing-paths'],

The execution order is respected.