-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Add template for document generation with 'jsdoc'. #3497
Conversation
In essence, it defines the subdirectory `docs` as a `jsdoc` template. Benefits: - allows the usage of partials, in order to DRY common parts of the html files. - makes available the jsdoc-comments, for addition into the documentation. - enables extraction of data from the source code. For example, the list of edge endpoints `['arrow', 'bar', 'circle']` can now be extracted from the source and inserted into the documentation on generation. In this initial version, the only file that has been changed is `docs/data/dataset.html`. In here, partials have been added to illustrate how common page elements can be DRY'd. The template has been set up in such a way, that resource files will be copied and that html files can pass through unchanged if no special template tags (`<?js...?>`) are used. This allows for a gradual transition of the html files to templates. **Usage:** `gulp docs` - The result files are placed in subdirectory `gen/docs/`. **NOTE:** The release procedure will have to be adjusted by adding this gulp command. The docs-files will then have to be taken from `gen/docs`.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks promising. Quite well documented.
I will have to pull it down and give it a try!
docs/README.md
Outdated
|
||
The `docs` directory is treated as a `jsdoc` template, in which the html-files are the template files. | ||
This allows for a gradual adaptation of the html-files to templates; unchanged html-files will pass | ||
through `jsdoc` unchanged. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be on the same line, and people can use word wrap in their ide to have the line break appropriately.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok. It should be readable as text as well, of course.
docs/README.md
Outdated
``` | ||
|
||
But it also appear to be possible to use the elements of docData directly: | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can get proper syntax highlighting by adding the name to your code block.
ie,
```javascript var docData =... ```
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
json is also a valid key word for syntax highlighting
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, I knew that, it just didn't occur to me to use it here.
var msg = 'js works as well.';
And now I learnt from you how to display ```js itself!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please do keep on reviewing! And yes try it out, please, if only to see if it works on machines other than mine.
hasError = true; | ||
cb(); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing semi-colon
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
gulpfile.js
Outdated
if (!hasError) { | ||
var params = '-c ./jsdoc.json -r -t docs -d ' + targetDir; | ||
child_exec('node ./node_modules/jsdoc/jsdoc.js ' + params + ' lib', undefined, cb); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unnecessary semi-colon
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Due to this, I linted gulpfile.js
and to my delight, I discovered that it's actually possible. What do you think, should it officially be added to the linting step?
I found that the index.html files did not work as I would have expected them to? Maybe this is a misunderstanding on my part. |
The top index.html has this redirect in it which possibly reconnects to the main site. But all the other, lower-level, index.html's should be just fine. The top-level index.html can be excused; do you have trouble with the other ones as well? |
Maybe I'm misunderstanding how to use this. If I navigate to dataset.html directly, everything looks fine. If I open the index.html file, I'm redirected, but file not found. If I copy and paste the entire file structure into the docs the gh-pages branch, replacing existing files, then the index pages work, but show file listings. It is entirely possible that this is just user error. In any case the generated dataset.html looks great. |
You're not misunderstanding anything; that's how the html files are set up. These pages are made to be integrated into the web site, as in
Perhaps you mean that they don't show? As for the greatness of the generated page, it should be just identical to the original version. Next step is to isolate all the common parts in partials - obvious candidates: the HTML at top and bottom, the menu's. And there are plenty more duplicates of data in the doc's themselves, e.g. font settings in both nodes and edges. Hoping for some help in converting them.... |
And will that also mean eventually incorporating documentation on the web page that is generated from some of the jsdoc in the source code itself? |
Oh yes, definitely. That is in fact the major point of this exercise. The rest is just nice consequences. |
Excellent! |
Since the whole point of using |
* Add template for document generation with 'jsdoc'. In essence, it defines the subdirectory `docs` as a `jsdoc` template. Benefits: - allows the usage of partials, in order to DRY common parts of the html files. - makes available the jsdoc-comments, for addition into the documentation. - enables extraction of data from the source code. For example, the list of edge endpoints `['arrow', 'bar', 'circle']` can now be extracted from the source and inserted into the documentation on generation. In this initial version, the only file that has been changed is `docs/data/dataset.html`. In here, partials have been added to illustrate how common page elements can be DRY'd. The template has been set up in such a way, that resource files will be copied and that html files can pass through unchanged if no special template tags (`<?js...?>`) are used. This allows for a gradual transition of the html files to templates. **Usage:** `gulp docs` - The result files are placed in subdirectory `gen/docs/`. **NOTE:** The release procedure will have to be adjusted by adding this gulp command. The docs-files will then have to be taken from `gen/docs`. * Edits to docs/README * Adjusted layout of README.md * Further edits to README.md * Removed pre tags again in README.md - don't work in code block * Linted the gulpfile * Added proof of concept for docs generation from source
In essence, this PR defines the subdirectory
docs
as ajsdoc
template.Benefits:
jsdoc
-comments, for addition into the documentation.['arrow', 'bar', 'circle']
can now be extracted from the source and inserted into the documentation on generation.In this initial version, the only file that has been changed is
docs/data/dataset.html
. Here, partials have been added to illustrate how common page elements can be DRY'd.The template has been set up in such a way, that resource files will be copied and that html files can pass through unchanged if no special template tags (
<?js...?>
) are used. This allows for a gradual transition of the html files to templates.A
README.md
has been added to subdirectorydocs
, with notes on how to use thejsdoc
-generated comment data.Usage:
gulp docs
gen/docs/
.NOTE: The release procedure will have to be adjusted by adding this gulp command.
The docs-files will then have to be taken from
gen/docs
.