Living documentation
See product documentation for more information.
To get started
npm install @synion/md-docs -g
mkdir ../documentation
cd documentation
mkdir docs
echo "# It works!" > docs/index.md
md-docs
google-chrome dist/index.html
Options
branches only
md-docs -b
Custom theme
You can override all assets files by adding the same files to docs folder: docs/assets/style/custom-theme.css can then be overwritten by a custom theme implementation.
Skip branches
md-docs -s branch1 branch2
To debug
Set the environment to development. All intermediate steps are saved as files in the dist directory.
export NODE_ENV=development
Product
md-docs is a cli tool which generates a static webiste by resolving files recursivly from a source folder.
This script copies every file and directory from the docs directory into the dist directory and transforms every *.md
file into a html file while adding the following features:
- Every *.md is transformed in a static web page;
- Every *.message.md is transformed in a static document web page and PDF;
- Every index.md is added to the menu;
- Every heading is automaticly converted into a container;
- Every
*.bpmn
anchor is automaticly converted into a bpmn.io viewer;fir - Every
*openapi.yaml
anchor is automaticly converted into a html documentation page; - Every
*asyncapi.yaml
anchor is automaticly converted into a html documentation page; - Every
*.feature
anchor is automaticly converted into a feature details list; - Every
*.dashboard.yaml
anchor is automaticly converted into a BDD dashboard; - Every
*.user-task.yaml
anchor is automaticly converted into a user-interface; - Every
*.puml
filer is automaticly converted into an svg image file; - Every
*.drawio
file is automaticly into an svg image file; - Every
*.java
, *.cs
, *.ts
, *.js
, *.json
, *.py
, *.yml
, *.yml
anchor is automaticly converted in a code block; - Every markdown anchor is automaticly converted into an html link;
- Every markdown anchor which starts with an
_
is automaticly added to the markdown file; - Every git branch is added to the git menu;
- Test executions are automaticly parsed in feature files;
- Unsorted list with items which reference the files above are automaticly converted in tab panels;
- Images are wrapped in figures;
- Images can be alligned by adding align=center or align=left or align=right to the url;
- Markdown is transformed into html using markdow-it, the following plugins are installed:
All links are relative so you do not need a webserver.
Architecture
The application is written in node js and implements a plug in architecture. It uses Awilix under the hood for dependency resolving. Plugins can be used by extending App and adding or replacing service registrations.
There are several plugin strategies:
- add or change the file parsers;
- add or change the html parsers;
- add or change the anchor parsers;
- change components;
- change component render functions;
module.exports = MyApp extends App {
constructor(options) {
super(options);
}
_getServices(options) {
const services = super(options);
services['newFileParser'] = asClass(NewFileParser).singleton();
services.fileParsers.push('newFileParser');
services['newHtmlParser'] = asClass(NewHtmlParser).singleton();
services.htmlParsers.push('newHtmlParser');
services['newAnchorParser'] = asClass(NewAnchorParser).singleton();
services.anchorParsers.push('newAnchorParser');
services.pageComponent = asClass(MyPageComponent).singleton();
services.pageComponentRenderFn = asValue((data) => '<html />');
return services;
}
}
Class diagram