mirror of
https://github.com/nasa/openmct.git
synced 2024-12-20 13:43:09 +00:00
[Documentation] Add clarifying comments
Add clarifying comments to doc generator, MissionControl/vista#21.
This commit is contained in:
parent
3dace28eb3
commit
320be34798
@ -1,7 +1,32 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* Open MCT Web, Copyright (c) 2014-2015, United States Government
|
||||||
|
* as represented by the Administrator of the National Aeronautics and Space
|
||||||
|
* Administration. All rights reserved.
|
||||||
|
*
|
||||||
|
* Open MCT Web is licensed under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
* License for the specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
* Open MCT Web includes source code licensed under additional open source
|
||||||
|
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||||
|
* this source code distribution or the Licensing information page available
|
||||||
|
* at runtime from the About dialog for additional information.
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
/*global require,process,GLOBAL*/
|
/*global require,process,GLOBAL*/
|
||||||
/*jslint nomen: true*/
|
/*jslint nomen: true*/
|
||||||
|
|
||||||
|
|
||||||
|
// Usage:
|
||||||
|
// node gendocs.js --in <source directory> --out <dest directory>
|
||||||
|
|
||||||
var CONSTANTS = {
|
var CONSTANTS = {
|
||||||
DIAGRAM_WIDTH: 800,
|
DIAGRAM_WIDTH: 800,
|
||||||
DIAGRAM_HEIGHT: 500
|
DIAGRAM_HEIGHT: 500
|
||||||
@ -22,6 +47,7 @@ GLOBAL.window = GLOBAL.window || GLOBAL; // nomnoml expects window to be define
|
|||||||
Canvas = require('canvas'),
|
Canvas = require('canvas'),
|
||||||
options = require("minimist")(process.argv.slice(2));
|
options = require("minimist")(process.argv.slice(2));
|
||||||
|
|
||||||
|
// Convert from nomnoml source to a target PNG file.
|
||||||
function renderNomnoml(source, target) {
|
function renderNomnoml(source, target) {
|
||||||
var canvas =
|
var canvas =
|
||||||
new Canvas(CONSTANTS.DIAGRAM_WIDTH, CONSTANTS.DIAGRAM_HEIGHT);
|
new Canvas(CONSTANTS.DIAGRAM_WIDTH, CONSTANTS.DIAGRAM_HEIGHT);
|
||||||
@ -29,6 +55,11 @@ GLOBAL.window = GLOBAL.window || GLOBAL; // nomnoml expects window to be define
|
|||||||
canvas.pngStream().pipe(fs.createWriteStream(target));
|
canvas.pngStream().pipe(fs.createWriteStream(target));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Stream transform.
|
||||||
|
// Pulls out nomnoml diagrams from fenced code blocks and renders them
|
||||||
|
// as PNG files in the output directory, prefixed with a provided name.
|
||||||
|
// The fenced code blocks will be replaced with Markdown in the
|
||||||
|
// output of this stream.
|
||||||
function nomnomlifier(outputDirectory, prefix) {
|
function nomnomlifier(outputDirectory, prefix) {
|
||||||
var transform = new stream.Transform({ objectMode: true }),
|
var transform = new stream.Transform({ objectMode: true }),
|
||||||
isBuilding = false,
|
isBuilding = false,
|
||||||
@ -70,6 +101,7 @@ GLOBAL.window = GLOBAL.window || GLOBAL; // nomnoml expects window to be define
|
|||||||
return transform;
|
return transform;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Convert from Github-flavored Markdown to HTML
|
||||||
function gfmifier() {
|
function gfmifier() {
|
||||||
var transform = new stream.Transform({ objectMode: true }),
|
var transform = new stream.Transform({ objectMode: true }),
|
||||||
markdown = "";
|
markdown = "";
|
||||||
@ -86,6 +118,8 @@ GLOBAL.window = GLOBAL.window || GLOBAL; // nomnoml expects window to be define
|
|||||||
return transform;
|
return transform;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Custom renderer for marked; converts relative links from md to html,
|
||||||
|
// and makes headings linkable.
|
||||||
function CustomRenderer() {
|
function CustomRenderer() {
|
||||||
var renderer = new marked.Renderer(),
|
var renderer = new marked.Renderer(),
|
||||||
customRenderer = Object.create(renderer);
|
customRenderer = Object.create(renderer);
|
||||||
@ -119,6 +153,9 @@ GLOBAL.window = GLOBAL.window || GLOBAL; // nomnoml expects window to be define
|
|||||||
smartypants: false
|
smartypants: false
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Convert all markdown files.
|
||||||
|
// First, pull out nomnoml diagrams.
|
||||||
|
// Then, convert remaining Markdown to HTML.
|
||||||
glob(options['in'] + "/**/*.md", {}, function (err, files) {
|
glob(options['in'] + "/**/*.md", {}, function (err, files) {
|
||||||
files.forEach(function (file) {
|
files.forEach(function (file) {
|
||||||
var destination = file.replace(options['in'], options.out)
|
var destination = file.replace(options['in'], options.out)
|
||||||
|
Loading…
Reference in New Issue
Block a user