0.0.5 • Published 7 years ago

md-docs-express v0.0.5

Weekly downloads
1
License
MIT
Repository
github
Last release
7 years ago

md-docs-express

md document router on express

Usage

var option = {
    mddir: require('path').join(__dirname, 'mddir'),
};

app.use('/docs', require('md-docs-express')(option));

API

md-docs-express(options)

returns

  • express router

options

  • mddir: Directory includes md files
  • hasSetting: if true, read \<mddir>/settings.json for various setting like listing order
  • debug: debug flag
  • title: page title
  • swaggerDoc: swagger document (json format)

settings.json

If there are 3 filesA.md, B.md, C.md are in mddir, you can set their order as following.

{
    "listorder": [
        "C",
        "A",
        "B"
    ]
}

Also you can specify directory name

mkdir subdir
{
    "listorder": [
        "C",
        "A",
        "B",
        "subdir"
    ]
}

Swagger document

If you want to display swagger doc, specify swaggerDoc to option.
The path of the SwaggerDoc will be \<path>/swagger.
Swagger json string will be exposed at \<path>/swagger/apidoc. Swagger-UI 2.2.10 is used.

var option = {
    mddir: require('path').join(__dirname, 'mddir'),
    swaggerDoc: {Swagger Doc json object}
};

app.use('/docs', require('md-docs-express')(option));

Known Issues

  • Subdirectory is now supported, but has 1-depth limitation

Demo

  1. create directories
mkdir mytest
cd mytest
mkdir documents
mkdir documents/subdir
  1. create example md files
touch documents/A.md
touch documents/B.md
touch documents/C.md
touch documents/subdir/D.md
touch documents/subdir/E.md
  1. Create express project
npm install express -g
express -e ./
npm install
npm install --save md-docs-express
  1. add page to app.js
app.use('/docs', require('md-docs-express')({
    mddir: require('path').join(__dirname, 'documents'),
    title: 'Hello World!'
}));
  1. Start app
node bin/www
  1. Look your page

http://localhost:8080/docs

picture1

picture2

0.0.5

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago