mirror of
https://github.com/xibyte/jsketcher
synced 2025-12-06 16:33:15 +01:00
documentation static generator
This commit is contained in:
parent
9c82d662b0
commit
e6d5b7b509
28 changed files with 1521 additions and 130 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -13,3 +13,4 @@
|
||||||
/node_modules
|
/node_modules
|
||||||
/dist
|
/dist
|
||||||
/.vs
|
/.vs
|
||||||
|
/web/docs/
|
||||||
82
Gruntfile.js
82
Gruntfile.js
|
|
@ -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) + '"';
|
||||||
|
});
|
||||||
|
}
|
||||||
75
modules/doc/doc-layout.handlebars
Normal file
75
modules/doc/doc-layout.handlebars
Normal 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>
|
||||||
|
|
@ -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
1381
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
|
@ -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",
|
||||||
|
|
|
||||||
|
|
@ -1,20 +0,0 @@
|
||||||
# BOOLEAN OPPERATIONS
|
|
||||||
|
|
||||||
Boolean operations allow for solids to be used as tools to shape and modify other solids.
|
|
||||||
|
|
||||||
|
|
||||||
# UNION
|
|
||||||
Union allows solids to be combined to create a new solid.
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
# 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.
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
# INTERSECTION
|
|
||||||
Intersection allows for the creation of a new solid in the space where 2 exising solids overlap.
|
|
||||||
|
|
||||||

|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
# BOX
|
|
||||||

|
|
||||||
|
|
||||||
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").
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
place holder
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
place holder
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
place holder
|
|
||||||
|
|
@ -1,13 +0,0 @@
|
||||||
# Datum Create
|
|
||||||

|
|
||||||
|
|
||||||
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 [DATUM_MOVE.md](DATUM_MOVE.md "DATUM_MOVE.md")
|
|
||||||
[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.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,9 +0,0 @@
|
||||||
# Datum Move
|
|
||||||

|
|
||||||
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
# Datum Rotate
|
|
||||||

|
|
||||||
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
place holder
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
Place holder
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
See [BOOLEAN_OPPERATIONS.md](BOOLEAN_OPPERATIONS.md "BOOLEAN_OPPERATIONS.md").
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
place holder
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
place holder
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
Place holder
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
place holder
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
See [BOOLEAN_OPPERATIONS.md](BOOLEAN_OPPERATIONS.md "BOOLEAN_OPPERATIONS.md").
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
place holder
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
place holder
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
place holder
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
See [BOOLEAN_OPPERATIONS.md](BOOLEAN_OPPERATIONS.md "BOOLEAN_OPPERATIONS.md").
|
|
||||||
|
|
@ -1,30 +0,0 @@
|
||||||
- [DATUM_CREATE.md](DATUM_CREATE.md "DATUM_CREATE.md")
|
|
||||||
- [DATUM_MOVE.md](DATUM_MOVE.md "DATUM_MOVE.md")
|
|
||||||
- [DATUM_ROTATE.md](DATUM_ROTATE.md "DATUM_ROTATE.md")
|
|
||||||
- [PLANE.md](PLANE.md "PLANE.md")
|
|
||||||
- [EditFace.md](EditFace.md "EditFace.md")
|
|
||||||
- [REVOLVE.md](REVOLVE.md "REVOLVE.md")
|
|
||||||
- [CUT.md](CUT.md "CUT.md")
|
|
||||||
- [FILLET.md](FILLET.md "FILLET.md")
|
|
||||||
|
|
||||||
|
|
||||||
- [ReassignSketch.md](ReassignSketch.md "ReassignSketch.md")
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
- [CYLINDER.md](CYLINDER.md "CYLINDER.md")
|
|
||||||
- [CONE.md](CONE.md "CONE.md")
|
|
||||||
- [SPHERE.md](SPHERE.md "SPHERE.md")
|
|
||||||
- [TORUS.md](TORUS.md "TORUS.md")
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
- [UNION.md](UNION.md "UNION.md")
|
|
||||||
- [SUBTRACT.md](SUBTRACT.md "SUBTRACT.md")
|
|
||||||
- [INTERSECTION.md](INTERSECTION.md "INTERSECTION.md")
|
|
||||||
|
|
||||||
|
|
||||||
- [StlExport.md](StlExport.md "StlExport.md")
|
|
||||||
- [Save.md](Save.md "Save.md")
|
|
||||||
|
|
||||||
- [index.md](index.md "index.md")
|
|
||||||
Loading…
Reference in a new issue