ngDocumentor is a simple website that serves your .md files from a host location and present it as a readable site. It is quite nice and useful for static sites that are generally used for documentation purposes. Just clone the ngDocumentor site repository, add your .md files, and add your link's configuration .json files. It can be as simple as that. Supports HTML only sites like github pages where there is no server configuration access to add url rewrites.
-
Clone the ngDocumentor github site repository OR download the latest release v3.0.0 to use the ngDocumentor site distribution directly.
-
NOTE: If you clone the ngDocumentor github site repository, and do not intend to use Service Worker / Offline viewing support then you can safely delete the
ngsw-worker.jsandngsw.jsonfiles from the github clone. Alternatively, if you wish to use the offline viewing (caching) support then use the ngDocumentor Angular source to create a offline viewing enabled build for yourself. Build steps for ngDocumentor development branch can be found here or in README.md. -
If you have created your markdown (.md files) wiki for your project, that should be your starting point. If not create your documentation. You can have a look at .md doc generation tips and support here. Copy all your
.mdfiles (with the respective folder structure, if needed) into theassets/docsfolder in the downloaded ngDocumentor release. In case of a cloned repository you will find the docs folder directly within thesrc/assetsfolder. -
Your site's sidebar, top, and footer navigation all can be dynamically specified using a single
settings.jsonconfiguration file insideassets/config/folder. -
The settings.json structure is simple consisting of
filetype, home, topnav, sidebar, footer, and searchkeys. The Top navigation definition resides intopnavkey, Sidebar menu definition insidebarkey, Footer navigation definition infooterkey, Landing page definition inhomekey, and Search keywords definitions insearchkey.
{
"filetype": "md", // file extension here
"home": { },
"topnav": { },
"sidebar": { },
"footer": { },
"search": { }
}
- Let us look at each one of them seperately.
-
There are three alternatives of
homekey definition based on, first, whether you want a landing page or not. Second, if you want a landing page, then choose slider or text based home page. -
homekey definition One
"home": {
"type": "landing",
"url": "/",
"highlight": {
"type": "text",
"img":"/assets/img/new-file-1.svg",
"heading": "ngDocumentor",
"description": "ngDocumentor can be as simple as you need. Max char size 250 chars.",
"buttontext": "Getting Started",
"buttonurl": "/intro"
},
"blocks": {
"heading": "ngDocumentor features flexibility for your documentation or your Site",
"items": [
{"title": "Reuse Markdown", "description" : "Use your markdown readme files to create the site.", "url": "/"}
]
}
}
homekey definition Two
"home": {
"type": "landing",
"url": "/",
"highlight": {
"type": "slider",
"img": [
{"url":"http://placeholder.pics/svg/300/00cec9-00cec9/00cec9-00cec9", "text":"ngDocumentor"}
]
},
"blocks": {
"heading": "ngDocumentor features flexibility for your documentation or your Site",
"items": [
{"title": "Reuse Markdown", "description" : "Use your markdown readme files.", "url": "/"}
]
}
}
-
homekey definition Three -
Create
assets/docs/home.mdfor top first level home link, if type of home settings istext. This is currently needed and not optional. [1]home.mdwill be path/home. For that matter you can name the file anything. But do not forget to use the url of home settings to be of the path corresponding to the filename without the extension.
"home": {
"type": "text",
"url": "/home" // for filename home.md to be homepage
}
-
Specify
brandname,logoandnavkeys to define thetopnavobject key, which take care of brandname and the links definition for the topnav respectively. -
Links inside the
navkey inside the topnav key is an array / group of objects which is defined usingtag(Link text), andlink(url path) definitions respectively as below. -
topnavkey definition
"topnav": {
"brandname": "My Documentation",
"logo": "/assets/img/logo.png",
"nav": [
{ "tag": "Home", "link": "/home" },
{ "tag": "Getting Started", "link": "/intro" }
]
}
-
Add any number of link structures below a maximum of 5 links in the topnav key. Do a responsiveness check for this. The topnavigation links are also unavailable in the mobile mode other than the brandname.
-
For convinience sake, the object
{"tag": "Link Title", "link": "LinkURL"}will be referred to as theLink Object; and this object is consistent across all settings.json key's configuration (topnav, sidebar, and footer).
-
You can specify a group / array of links object (submenu link items) using the
tag(Link text), andlinkin thenavkey of the sidebar key. -
One basic difference between the topnav and sidebar keys are that you can specify
childrenin sidebar (unavailable in the top navigation key definition). The definition for children array / group is the same as for other sidebar links object (and will havetagandlinkkeys). The example is as below: -
sidebarkey definition
"sidebar": {
"nav": [
{ "tag": "Home", "link": "/home" },
{ "tag": "Getting Started - 10 mins", "link": "/intro" }
]
}
- Add any number of link object structures in the sidebar key definition. There is no restriction on the same.
-
Footer is the only section that needs a different look to its
footerkey definition due to sections present in the footer. The links object structure used anywhere, however, remains the same. -
footerkey definition
"footer": {
"copyright": {
"tag": " { ngDocumentor } ",
"link": "/home",
"type": "external",
"text": "ngDocumentor is a simple markdown rendering site framework that works even on HTML only hosts like github pages",
},
"nav": [
{
"tag": "Footer Example 1",
"children": [
{ "tag": "Getting Started", "link": "/intro" },
{ "tag": "Config .json Files", "link": "/config" }
]
}
],
"social": [
{ "tag": "Google +", "link": "/intro" }
]
}
-
The
footerkey definition has three keyscopyright,nav, andsocialeach catering to copyright, navigation, and social links sections respectively in the Footer; as the name suggests. -
The
copyrightkey defines a link object withtag, andlinkkeys. There is another keytextwhich allows for addition of text just before the copyright text in the bottom. Have a look at this site's footer. -
The
navkey defines footer navigation section categories each withtagandchildrenkeys. Thetagkey defines the the heading of the footer navigation sub-section. Thechildrenkey again defines an array / group of links objects withtagandlinkkeys. -
The
socialkey defines social links section in the footer using an array of link objects withtagandlinkkeys.
-
The search definition details what type of search you want to use - full text search or keyword search.
-
searchkey definition One
"search": {
"type": "keywords", // TODO Item
"meta": [
{"url": "/home", "keywords": ["angular"]},
{"url": "/intro", "keywords": ["test"]}
]
}
searchkey definition One
"search": {
"type": "fulltext",
"stopwords": [] // TODO Item
}
-
NOTE: Please do not forget to change the
<base href="/">to<base href="/yoursubfolder/">server subfolder path in theindex.html, if your hosting folder path is not in the root. If the site repository is going to be in the root hosting folder, do not worry about this aspect. -
NOTE: All .md files including home.md will map to
/FILENAME(without .md) url path for .json configuration files. Example:assets/docs/introduction.mdwill be mapped to link/introduction. Similarly,assets/docs/mysubfolder/introduction.mdwill be mapped to linkmysubfolder/introduction. -
EXCEPTION NOTE: If you want to reference other markdown files within your markdown files as internal links then use a
#in from of your links. Example:assets/docs/somefile.mdwill be referred as#/somefilelike this[Some File](#/somefile)inside the referencing file. This is currently a requirement. If you think we can avoid it, please send a pull request. Link inside .md file for Topnav - Demo. -
Thats it! Push your code to your server root or folder. Your simple documentation site is online.
- Move to Observable based routing P3
- Add support for bookmarks P3
- Add keyword based search for large doc size P3
- Better normalized search for fuzzy/full word search and support for weighted searches P3
- Add Tests P2
- Add settings support using .yaml, .xml P3
MIT