Skip to content
This repository has been archived by the owner on Apr 17, 2023. It is now read-only.

[RAINCATCH 1399] Docs improvements #152

Merged
merged 5 commits into from Nov 30, 2017
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions README.adoc
Expand Up @@ -63,12 +63,14 @@ Setup required packages (Node.js/npm required)

Publishing

npm run buildAsciiDocs
npm run buildApiDocs
npm run build:docs
npm run build:api
npm run publish

NOTE: _ascidoctor_ needs to be installed on machine. To install asciidoctor run _gem install asciidoctor_

NOTE: The `build:api` command relies on the generated API documentation from the core repository to be present at `./api/`. In order to supply a custom path, use `npm run build:api -- -f 'path/to/raincatcher-core/docs/api'`

==== Watching for changes

The `npm run watch` command will execute the previous build commands and run a local server for viewing the generated documentation website.
Expand Down
Expand Up @@ -8,28 +8,28 @@ The latest list of modules is found at link:https://www.npmjs.com/org/raincatche
|===
|Module |Description

|link:../../../api/{WFM-RC-Api-Version}/express-auth/docs/index.html[@raincatcher/express-auth]
|link:../../../api/{WFM-RC-Api-Version}/express-auth/index.html[@raincatcher/express-auth]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😍

|The {PROJECT_NAME} Security Interface is used to apply authentication and authorization, used in conjunction with a security provider chosen by you.

|link:../../../api/{WFM-RC-Api-Version}/auth-passport/docs/index.html[@raincatcher/auth-passport]
|link:../../../api/{WFM-RC-Api-Version}/auth-passport/index.html[@raincatcher/auth-passport]
|The {PROJECT_NAME} implementation of Passport.js which is the default security module for Mobile and Portal applications.

|link:../../../api/{WFM-RC-Api-Version}/datasync-cloud/docs/index.html[@raincatcher/datasync-cloud]
|link:../../../api/{WFM-RC-Api-Version}/datasync-cloud/index.html[@raincatcher/datasync-cloud]
|The {PROJECT_NAME} Cloud implementation of fh-sync used in conjunction with @raincatcher/datasync-client. This is used to sync data between the Cloud and Mobile applications.

|link:../../../api/{WFM-RC-Api-Version}/datasync-client/docs/index.html[@raincatcher/datasync-client]
|link:../../../api/{WFM-RC-Api-Version}/datasync-client/index.html[@raincatcher/datasync-client]
|The {PROJECT_NAME} Client implementation of fh-sync used in conjunction with @raincathcer/datasync-cloud. This is used to sync data between the Cloud and Mobile applications.

|link:../../../api/{WFM-RC-Api-Version}/wfm/docs/index.html[@raincatcher/wfm]
|link:../../../api/{WFM-RC-Api-Version}/wfm/index.html[@raincatcher/wfm]
|The {PROJECT_NAME} Work Flow Management module which allows developers to map a business process into an organized set of tasks to suit a businesses needs.

|link:../../../api/{WFM-RC-Api-Version}/wfm-rest-api/docs/index.html[@raincatcher/wfm-rest-api]
|link:../../../api/{WFM-RC-Api-Version}/wfm-rest-api/index.html[@raincatcher/wfm-rest-api]
|The {PROJECT_NAME} Work Flow Management API module exposes express API endpoints for Work Flow Management Objects.

|link:../../../api/{WFM-RC-Api-Version}/wfm-user/docs/index.html[@raincatcher/wfm-user]
|link:../../../api/{WFM-RC-Api-Version}/wfm-user/index.html[@raincatcher/wfm-user]
|The {PROJECT_NAME} Aggregates all user operations for {PROJECT_NAME} modules.

|link:../../../api/{WFM-RC-Api-Version}/wfm-demo-data/docs/index.html[@raincatcher/wfm-demo-data]
|link:../../../api/{WFM-RC-Api-Version}/wfm-demo-data/index.html[@raincatcher/wfm-demo-data]
|This is a sample module containing static data definitions and when running, it allows the user to see the {PROJECT_NAME} demo project example.

|===
11 changes: 6 additions & 5 deletions package.json
Expand Up @@ -4,11 +4,12 @@
"description": "RainCatcher website source code",
"main": "index.js",
"scripts": {
"buildAsciiDocs": "node ./website/cli.js asciidocs-build",
"buildApiDocs": "node ./website/cli.js apidocs-build",
"buildall": "npm run buildAsciiDocs && npm run buildApiDocs",
"watch": "nodemon -e adoc,xml,png,svg,js,css -w docs/ -w api/ -w resources/ --exec 'npm run buildall && http-server website/'",
"publishPage": "node ./website/cli.js publish"
"build:docs": "node ./website/cli.js asciidocs-build",
"build:api": "node ./website/cli.js apidocs-build",
"build:all": "npm run build:docs && npm run build:api",
"watch": "nodemon -e adoc,xml,png,svg,js,css -w docs/ -w api/ -w resources/ --exec 'npm run build:all && npm run serve'",
"serve": "http-server website/",
"publish": "node ./website/cli.js publish"
},
"dependencies": {
"fs-extra": "^4.0.1",
Expand Down
127 changes: 66 additions & 61 deletions website/cli.js
@@ -1,84 +1,89 @@
var spawn = require('child_process').spawn;
var yargs = require('yargs');
var fs = require('fs');
var path = require('path');
const spawn = require('child_process').spawn;
const yargs = require('yargs');
const fs = require('fs');
const path = require('path');
const fse = require('fs-extra')
var ghpages = require('gh-pages');
var moment = require('moment');
const ghpages = require('gh-pages');
const moment = require('moment');

var pageRoot = './website';
var ascidocsPath = '../docs/workforce-management-framework/upstream-1';
var docRoot = path.join(__dirname, ascidocsPath).normalize()
const pageRoot = './website';
const ascidocsPath = '../docs/workforce-management-framework/upstream-1';
const docRoot = path.join(__dirname, ascidocsPath).normalize()

yargs.usage('Usage: $0 <command>')
.command('asciidocs-build',
'Build asciidocs documentation. Requires: asciidoctor', function(yargs) {
}, asciidocsHandler)
.command('apidocs-build', 'Copy documentation folder', function(yargs) {
}, apiHandler)
.command('publish', 'Publish website to github pages', function(yargs) {
}, publishHandler)
.demandCommand()
.help()
.argv;
.command('asciidocs-build',
'Build asciidocs documentation. Requires: asciidoctor', function(yargs) {
}, asciidocsHandler)
.command('apidocs-build', 'Copy documentation folder', function(yargs) {
yargs
.alias('f', 'folder')
.default('folder', './api')
}, apiHandler)
.command('publish', 'Publish website to github pages', function(yargs) {
}, publishHandler)
.demandCommand()
.help()
.argv;


function apiHandler(argv) {
return copyApiFiles();
return copyApiFiles(argv);
}

function publishHandler(argv) {
return publishWebsite();
return publishWebsite();
}

function asciidocsHandler(argv) {
return buildAsciDocs(function(err) {
if (err) {
console.log("Failed to build ascidocs page", err);
return process.exit(1);
}
console.log("Created documentation file");
fse.moveSync(path.join(docRoot, "master.html"), pageRoot + '/docs/index.html',
{ overwrite: true });
fse.copySync(path.join(docRoot, "/topics/shared/images"), pageRoot + '/docs/images',
{ overwrite: true });
console.log("Documentation copied to website");
});
return buildAsciDocs(function(err) {
if (err) {
console.log("Failed to build ascidocs page", err);
return process.exit(1);
}
console.log("Created documentation file");
fse.moveSync(path.join(docRoot, "master.html"), pageRoot + '/docs/index.html',
{ overwrite: true });
fse.copySync(path.join(docRoot, "/topics/shared/images"), pageRoot + '/docs/images',
{ overwrite: true });
console.log("Documentation copied to website");
});
}

function publishWebsite() {
var options = {
branch: 'gh-pages',
remote: 'origin',
dotfiles: 'true'
var options = {
branch: 'gh-pages',
remote: 'origin',
dotfiles: 'true'
}
ghpages.publish(pageRoot, options, function(err) {
if (err) {
return console.error("Page failed to publish", err);
}
ghpages.publish(pageRoot, options, function(err) {
if (err) {
return console.error("Page failed to publish", err);
}
console.info("Page published");
});
console.info("Page published");
});
}

function copyApiFiles() {
fse.copySync('./api', pageRoot + '/api', { overwrite: true });
console.log("Created api documentation");
function copyApiFiles(args) {
const { folder } = args;
console.log(`Copying file information from ${folder}`)
fse.copySync(folder, pageRoot + '/api', { overwrite: true });
console.log("Created api documentation");
};

function buildAsciDocs(cb) {
var args = ['master.adoc'];
var process = spawn('asciidoctor', args, { cwd: docRoot });
process.on('message', function(message) {
console.info("Asciidocs", message);
});
process.on('error', function(message) {
console.error("Asciidocs", message);
});
process.on('close', function(status) {
if (status === 0) {
cb && cb();
} else {
cb && cb(new Error("Command failed with status " + status));
}
});
var args = ['master.adoc'];
var process = spawn('asciidoctor', args, { cwd: docRoot });
process.on('message', function(message) {
console.info("Asciidocs", message);
});
process.on('error', function(message) {
console.error("Asciidocs", message);
});
process.on('close', function(status) {
if (status === 0) {
cb && cb();
} else {
cb && cb(new Error("Command failed with status " + status));
}
});
}