documentation static generator

This commit is contained in:
Mike Molinari 2022-07-31 11:25:12 +00:00 committed by Val Erastov
parent 9c82d662b0
commit e6d5b7b509
28 changed files with 1521 additions and 130 deletions

1
.gitignore vendored
View file

@ -13,3 +13,4 @@
/node_modules /node_modules
/dist /dist
/.vs /.vs
/web/docs/

View file

@ -3,10 +3,14 @@ const webpack = require('webpack');
const webpackConfig = require('./webpack.config'); const webpackConfig = require('./webpack.config');
const del = require('del'); const del = require('del');
const libAssets = require("./build/libAssets"); const libAssets = require("./build/libAssets");
const glob = require("glob");
const marked = require("marked");
const Handlebars = require("handlebars");
const exec = require('child_process').exec; const exec = require('child_process').exec;
module.exports = function(grunt) { module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-contrib-copy'); grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-watch');
function dirFilter(dirsToFilter) { function dirFilter(dirsToFilter) {
return (path) => { return (path) => {
@ -19,7 +23,14 @@ module.exports = function(grunt) {
} }
} }
let DOCS_PATTERN = '*/features/*/docs/**';
grunt.initConfig({ grunt.initConfig({
watch: {
docs: {
files: ['modules/workbenches/' + DOCS_PATTERN],
tasks: ['gen-docs']
}
},
copy: { copy: {
@ -38,8 +49,14 @@ module.exports = function(grunt) {
src: '**', src: '**',
dest: 'dist/', dest: 'dist/',
filter: dirFilter(['web/app', 'web/test']) filter: dirFilter(['web/app', 'web/test'])
} },
docs: {
cwd: 'modules/workbenches',
src: DOCS_PATTERN,
dest: 'web/docs',
expand: true
},
} }
}); });
@ -74,4 +91,67 @@ module.exports = function(grunt) {
}); });
grunt.registerTask('default', ['clean', 'build', 'copy:resources', 'copy:lib_assets', 'mark-revision', 'show-revision']); grunt.registerTask('default', ['clean', 'build', 'copy:resources', 'copy:lib_assets', 'mark-revision', 'show-revision']);
grunt.registerTask('gen-docs', ['copy:docs', 'process-markdown']);
grunt.registerTask('process-markdown', function() {
const done = this.async();
const mainTemplate = Handlebars.compile(grunt.file.read("modules/doc/doc-layout.handlebars"));
glob("web/docs/**/*.md", function (er, files) {
const workbenches = new Map();
files.forEach(file => {
const parts = file.split('/');
const workbenchName = parts[2];
const operationName = parts[4];
let workbench = workbenches.get(workbenchName);
if (!workbench) {
workbench = {
workbenchName,
operations: []
};
workbenches.set(workbenchName, workbench);
}
workbench.operations.push({
operationName,
href: '../../../../../../' + convertMdPathToHtml(file)
});
});
const sidenav = Array.from(workbenches.values());
files.forEach(file => {
const content = grunt.file.read(file);
const dest = convertMdPathToHtml(file);
const htmlContent = mainTemplate({
sidenav,
content: fixLinks(marked(content))
});
grunt.file.write(dest, htmlContent);
console.log("generated "+ dest);
})
done();
});
});
grunt.registerTask('docs-start', ['gen-docs', 'watch:docs']);
}; };
function convertMdPathToHtml(mdPath) {
return mdPath.substring(0, mdPath.length-('.md'.length)) + '.html';
}
function fixLinks(htmlContent) {
return htmlContent.replace(/href=['"](.+)['"]/g, function(expr, link){
return 'href="' + convertMdPathToHtml(link) + '"';
});
}

View file

@ -0,0 +1,75 @@
<html>
<head>
<title>Web CAD Documentation</title>
<link rel="shortcut icon" href="img/cad/cube96.png"/>
<style>
html {
height: 100%;
margin: 0;
}
body {
font-size: 14px;
font-family: 'DejaVu Serif', Georgia, "Times New Roman", Times, serif;
height: 100%;
display: flex;
flex-direction: column;
margin: 0;
}
.header {
border-bottom: 1px solid #000;
padding: 10px
}
.left {
padding: 10px;
border-right: 1px solid #000;
}
.content {
padding: 10px;
max-width: 600px;
}
.center {
display: flex;
flex-grow: 1;
}
.block-link {
display: block;
}
.children {
padding-left: 10px;
}
</style>
</head>
<body>
<div class="header">
JSketcher Documentation
</div>
<div class="center">
<div class="left">
{{#each sidenav}}
<div><b>{{workbenchName}}</b></div>
<div class="children">
{{#each operations}}
<a class="block-link" href="{{href}}">{{operationName}}</a>
{{/each}}
</div>
{{/each}}
</div>
<div class="content">
{{{content}}}
</div>
</div>
</body>
</html>

View file

@ -65,7 +65,6 @@ export const PrimitiveBoxOperation: OperationDescriptor<PrimitiveBoxParams> = {
run: (params: PrimitiveBoxParams, ctx: ApplicationContext) => { run: (params: PrimitiveBoxParams, ctx: ApplicationContext) => {
let occ = ctx.occService; let occ = ctx.occService;
const oci = occ.commandInterface; const oci = occ.commandInterface;

1381
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -5,6 +5,7 @@
"scripts": { "scripts": {
"start": "node ./node_modules/webpack-dev-server/bin/webpack-dev-server.js --config webpack.config.js --port 3000 --host 0.0.0.0", "start": "node ./node_modules/webpack-dev-server/bin/webpack-dev-server.js --config webpack.config.js --port 3000 --host 0.0.0.0",
"pack": "node ./node_modules/webpack/bin/webpack.js --config webpack.config.js --progress --profile --colors", "pack": "node ./node_modules/webpack/bin/webpack.js --config webpack.config.js --progress --profile --colors",
"start-with-docs": "concurrently --kill-others 'npm start' './node_modules/grunt/bin/grunt docs-start'",
"build": "grunt", "build": "grunt",
"lint": "eslint web/app", "lint": "eslint web/app",
"cypress": "npx cypress open" "cypress": "npx cypress open"
@ -42,6 +43,7 @@
"babel-loader": "^8.1.0", "babel-loader": "^8.1.0",
"babel-plugin-transform-decorators-legacy": "^1.3.5", "babel-plugin-transform-decorators-legacy": "^1.3.5",
"babel-polyfill": "^6.26.0", "babel-polyfill": "^6.26.0",
"concurrently": "^7.3.0",
"css-loader": "^3.4.2", "css-loader": "^3.4.2",
"cypress": "^4.7.0", "cypress": "^4.7.0",
"cypress-wait-until": "^1.7.1", "cypress-wait-until": "^1.7.1",
@ -51,8 +53,11 @@
"eslint-plugin-import": "^2.20.1", "eslint-plugin-import": "^2.20.1",
"eslint-plugin-react": "^7.19.0", "eslint-plugin-react": "^7.19.0",
"file-loader": "^6.2.0", "file-loader": "^6.2.0",
"glob": "^8.0.3",
"grunt": "^1.1.0", "grunt": "^1.1.0",
"grunt-contrib-copy": "1.0.0", "grunt-contrib-copy": "1.0.0",
"grunt-contrib-watch": "^1.1.0",
"handlebars": "^4.7.7",
"less-loader": "^5.0.0", "less-loader": "^5.0.0",
"less-vars-loader": "^1.1.0", "less-vars-loader": "^1.1.0",
"raw-loader": "^4.0.0", "raw-loader": "^4.0.0",

View file

@ -1,20 +0,0 @@
# ![](../img/cad/union32.png)![](../img/cad/subtract32.png)![](../img/cad/intersection32.png)BOOLEAN OPPERATIONS
Boolean operations allow for solids to be used as tools to shape and modify other solids.
# ![](../img/cad/union32.png)UNION
Union allows solids to be combined to create a new solid.
![](img/bool-UNION.gif)
# ![](../img/cad/subtract32.png)SUBTRACT
Subtract allows one solid to be used as a cuttong tool for another sold. Usefull for making hole features.
Selection A will have selection B removed from it.
![](img/bool-SUBTRACT.gif)
# ![](../img/cad/intersection32.png)INTERSECTION
Intersection allows for the creation of a new solid in the space where 2 exising solids overlap.
![](img/bool-INTERSECTION.gif)

View file

@ -1,7 +0,0 @@
# ![](../img/cad/cube32.png)BOX
![](img/box-dialog.gif)
The BOX command can be accesed by hovering over the center point of an existing datum and clicking. This brings up a menue with the BOX command as an option.
Size of the box can be specified with the width, height and depth fields.
The boolean drop down allows for boolean operations with existing 3d solids. See [BOOLEAN_OPPERATIONS.md](BOOLEAN_OPPERATIONS.md "BOOLEAN_OPPERATIONS.md").

View file

@ -1 +0,0 @@
place holder

View file

@ -1 +0,0 @@
place holder

View file

@ -1 +0,0 @@
place holder

View file

@ -1,13 +0,0 @@
# ![](../img/cad/datum32.png)Datum Create
![](img/create-datum.gif)
While the CREATE DATUM dialog is open the datum can be dragged using the vector arrows. Optionally the values can be enter in the fields of the dialog.
Datiums consist of a point and 3 vectors defining a relative location and orientation. The location and orientation can be moved after initial creation. See ![](../img/cad/datum-move32.png)[DATUM_MOVE.md](DATUM_MOVE.md "DATUM_MOVE.md")
![](../img/cad/datum-rotate32.png)[DATUM_ROTATE.md](DATUM_ROTATE.md "DATUM_ROTATE.md")
The datium feature provides a point that can be used as the baisus for plane features or the origin point of a 3d primitive.
The datium feature also provides 3 vectors. These vectors can be used for defining a direction of an extride/cut or the acces of a revolve feature.

View file

@ -1,9 +0,0 @@
# ![](../img/cad/datum-move32.png)Datum Move
![](img/move-datum.gif)
The MOVE DATUM dialog can be accesed by hovering over the center point of an existing datum and clicking. This brings up a menue with the MOVE DATUM command as an option.
While the MOVE DATUM dialog is open the datum can be dragged using the vector arrows. Optionally the values can be enter in the fields of the dialog.
Optionally a new copy of the exisintg datum can be created rather than the translation of the original.

View file

@ -1,7 +0,0 @@
# ![](../img/cad/datum-rotate32.png)Datum Rotate
![](img/rotate-datum.gif)
The ROTATE DATUM dialog can be accesed by hovering over the center point of an existing datum and clicking. This brings up a menue with the ROTATE DATUM command as an option.
While the ROTATE DATUM dialog is open the rotational axis can be selected. An angle then can be entered to change the orientation of datum.

View file

@ -1 +0,0 @@
place holder

View file

@ -1 +0,0 @@

View file

@ -1 +0,0 @@
Place holder

View file

@ -1 +0,0 @@
See [BOOLEAN_OPPERATIONS.md](BOOLEAN_OPPERATIONS.md "BOOLEAN_OPPERATIONS.md").

View file

@ -1 +0,0 @@
place holder

View file

@ -1 +0,0 @@
place holder

View file

@ -1 +0,0 @@
Place holder

View file

@ -1 +0,0 @@
place holder

View file

@ -1 +0,0 @@
See [BOOLEAN_OPPERATIONS.md](BOOLEAN_OPPERATIONS.md "BOOLEAN_OPPERATIONS.md").

View file

@ -1 +0,0 @@
place holder

View file

@ -1 +0,0 @@
place holder

View file

@ -1 +0,0 @@
place holder

View file

@ -1 +0,0 @@
See [BOOLEAN_OPPERATIONS.md](BOOLEAN_OPPERATIONS.md "BOOLEAN_OPPERATIONS.md").

View file

@ -1,30 +0,0 @@
- ![](../img/cad/datum32.png)[DATUM_CREATE.md](DATUM_CREATE.md "DATUM_CREATE.md")
- ![](../img/cad/datum-move32.png)[DATUM_MOVE.md](DATUM_MOVE.md "DATUM_MOVE.md")
- ![](../img/cad/datum-rotate32.png)[DATUM_ROTATE.md](DATUM_ROTATE.md "DATUM_ROTATE.md")
- ![](../img/cad/plane32.png)[PLANE.md](PLANE.md "PLANE.md")
- ![](../img/cad/face-edit96.png)[EditFace.md](EditFace.md "EditFace.md")
- ![](../img/cad/revolve32.png)[REVOLVE.md](REVOLVE.md "REVOLVE.md")
- ![](../img/cad/cut32.png)[CUT.md](CUT.md "CUT.md")
- ![](../img/cad/fillet32.png)[FILLET.md](FILLET.md "FILLET.md")
- ![](../img/cad/xxxxxxxx.png)[ReassignSketch.md](ReassignSketch.md "ReassignSketch.md")
- ![](../img/cad/cylinder32.png)[CYLINDER.md](CYLINDER.md "CYLINDER.md")
- ![](../img/cad/cone32.png)[CONE.md](CONE.md "CONE.md")
- ![](../img/cad/sphere32.png)[SPHERE.md](SPHERE.md "SPHERE.md")
- ![](../img/cad/torus32.png)[TORUS.md](TORUS.md "TORUS.md")
- ![](../img/cad/union32.png)[UNION.md](UNION.md "UNION.md")
- ![](../img/cad/subtract32.png)[SUBTRACT.md](SUBTRACT.md "SUBTRACT.md")
- ![](../img/cad/intersection32.png)[INTERSECTION.md](INTERSECTION.md "INTERSECTION.md")
- ![](../img/cad/stl32.png)[StlExport.md](StlExport.md "StlExport.md")
- ![](../img/cad/cone32.png)[Save.md](Save.md "Save.md")
- [index.md](index.md "index.md")