Code Monkey home page Code Monkey logo

docstrap's Introduction

Docstrap

Documentation generator.

Instalation

npm i @rebelstack-io/docstrap -g

Usage

docstrap [ -d | --dir=<path>] [<args>]

if no dir provided will generate documentation webview in docs folder

Configuration file

For better results is recomended to add a configuration file wich contains basic information such name of your project, keywords, views sections and more. This file must be in the route where you execute the docstrap command with the name .docstrap.js.

  • example
	'theme': 'default',
	'name': 'Docstrap',
	'description': 'Docstrap is an open-source library, allows you to generate documentation web-view for your projects in a organize and lightweight way',
	'discord': '#linktodiscord',
	'benefits': [
		`<div class="porperty">
			<i class="fas fa-feather-alt"></i>
			<h3>Lightweight</h3>
			<p>
				Docstrap scales well without adding overhead to the application. Generated files ara Plain vanilla HMTL-CSS-JS.
			</p>
		</div>`,
		`<div class="porperty">
			<i class="fas fa-tachometer-alt"></i>
			<h3>Fast</h3>
			<p>
				Docstrap use NodeJS alone, avoiding convoluted frameworks so your documentation can be generated by yourself or CI/CD process in an optimal way.
			</p>
		</div>`
	],
	'links': [
		`<a href="#expressif">
			<img src="img/expressif-boxmodel.jpeg" alt="expressif logo">
		</a>`,
		`<a href="#metaflux">
			<img src="img/metaflux-logo-black.svg" alt="expressif logo">
		</a>`
	],
	'repository': 'https://github.com/rebelstackio/docstrap.git'

this is not mandatory, it will generate the view eather way without a configuration file, you latter can modify your just generated HTML files with the info for your project.

Documentation structure

.
+-- community
|	+-- index.html
+-- css
|	+-- general.css
|	+-- main.css
|	+-- responsive.css
+-- docs
|	+-- api
|	|	+-- api-reference.md
|	|	+-- index.html
|	+-- examples
|	|	+-- examples.md
|	|	+-- index.html
|	+-- faq
|	|	+-- faq.md
|	|	+-- index.html
|	+-- getting-started
|	|	+-- getting-started.md
|	|	+-- index.html
|	+-- overview
|	|	+-- overview.md
|	|	+-- index.html
+-- img
|	+-- default-logo-white.svg
|	+-- default-logo.svg
+-- js
|	+-- index.js
|	+-- markdown.js
+-- index.html

Notice that there are some HTML files with .md files, the idea is to keep writing your documentation as you're used to, we then parse every MD file to the web view, all this is done in the server-side, so your HTML files will be fully statics helping with loading time and SEO, so don't forget to build your docstrap when a change to the .md files, or just leave it to Travis, Jenkins or the CI of your choice.

But what's under the hood? how does it work?

Docstrap is really simple what it does, we have a template already make wich only changes a few parts of the web view, such as project name, description, links for repositories or related contend.

It uses fs-extra to cp how the bash command cp -R would do, the template is copied to a directory you provide or docs/ folder for default.

All the HTML files in the template have those configuration variables with the convection {{varName}}, as long a variable in the config file has the same name as the ones in the HTML will replace it for the variable value, so we can map how many variables to the template we want.

  • variable example in the template
<title>{{name}}</title>
  • variable in the config file
..., 'name': 'Docstrap', ...

that is made by this util function

function parseConfigToHTML(htmlSTR, config) {
	const varMatch = htmlSTR.match(new RegExp('(?<=\{\{).+?(?=\}\})','g'));
	let resp = htmlSTR;
	varMatch.forEach((_v) => {
		let value = config[_v];
		resp = resp.replace(new RegExp(`\{\{${_v}\}\}`, 'g'), value)
	});
	return resp;
}

docstrap's People

Contributors

oreyes1991 avatar jegj avatar reinsbrain avatar

Watchers

James Cloos avatar  avatar  avatar Pablo Limo avatar

Forkers

oreyes1991

docstrap's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.