Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ph1p committed Apr 29, 2018
0 parents commit b380ffe
Show file tree
Hide file tree
Showing 23 changed files with 1,522 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
2 changes: 2 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
example/
src/
22 changes: 22 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Copyright (c) 2018 Philip Stapelfeldt

Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
99 changes: 99 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# static-site-jsdoc

[![npm](https://img.shields.io/npm/v/static-site-jsdoc.svg)](https://www.npmjs.com/package/static-site-jsdoc)

This npm package is a command line script, which scans your JavaScript or Typescript source code and generates markdown files with the help of [jsdoc-to-markdown](https://github.com/jsdoc2md/jsdoc-to-markdown).
These markdown files can be used in static site generators like vuepress.

## How to use?

```bash
npm i static-site-jsdoc -g
```

**Example:**

```bash
static-site-jsdoc --source=./src --dist=./documentation --folder=./code --title=API
```

### Options

|name|default|description|
|-|-|-|
|--source=|./src|Source folder with .js or .ts files|
|--dist=|./documentation|Destination folder|
|--folder=|./code|Folder inside destination folder. Gets overwritten everytime|
|--title=|./API|Title of your documentation|

### config.js

Inside your generated md files, you can find a `config.js`.
This file includes a complete filetree and an vuepress sidebar tree.

## Vuepress

[Vuepress](https://vuepress.vuejs.org/) is a new static site generator by Evan You.
You can add all generated documentation files to your existing vuepress project or create a new one.

```bash
# First install vuepress
npm i vuepress -g

# Run the CLI
static-site-jsdoc

# Run vuepress dev server
vuepress dev ./documentation

# Run vuepress build, if you want to ship it
vuepress build ./documentation
```

**Access it via:** http://localhost:8080/code/

Now you need the sidebar navigation.
Create a `.vuepress` folder inside `documentation` if it does not exist and add a `config.js`.

**Example:**

```javascript
// auto generated sidebar
const { sidebarTree } = require('../code/config');

module.exports = {
dest: 'documentation',
locales: {
'/': {
title: 'static-site-jsdoc',
description: 'A JSDoc cli to build md files for static site generators'
}
},
themeConfig: {
editLinks: true,
sidebarDepth: 4,
docsDir: 'code',
locales: {
'/': {
nav: [
{
text: 'Home',
link: '/'
}
],
// Add sidebar
sidebar: Object.assign({}, sidebarTree)
}
}
}
};
```
## Example

The `./example` folder includes a full working vuepress example generated from `./src`.

## ToDo

- [] Update description README.md
- [] Custom README.md
- [] Custom meta data
36 changes: 36 additions & 0 deletions example/.vuepress/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
const { sidebarTree } = require('../code/config');

module.exports = {
dest: 'documentation',
head: [
[
'link',
{
rel: 'icon',
href: `/logo.png`
}
]
],
locales: {
'/': {
title: 'static-site-jsdoc',
description: 'A JSDoc cli to build md files for static site generators'
}
},
themeConfig: {
editLinks: true,
sidebarDepth: 4,
docsDir: 'docs',
locales: {
'/': {
nav: [
{
text: 'Home',
link: '/'
}
],
sidebar: Object.assign({}, sidebarTree)
}
}
}
};
9 changes: 9 additions & 0 deletions example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
home: true
title: Blogging Like a Hacker
actionText: documentation →
actionLink: /code/
footer: Ph1p
---

Example page static-site-jsdoc
1 change: 1 addition & 0 deletions example/code/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Welcome
49 changes: 49 additions & 0 deletions example/code/class.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---
title: class
---
<a name="Test"></a>

## Test**Kind**: global class

* [Test](#Test)
* [new Test()](#new_Test_new)
* _instance_
* [.name](#Test+name)
* [.name](#Test+name)
* [.generateFullName()](#Test+generateFullName)
* _static_
* [.Test](#Test.Test)
* [new Test([name])](#new_Test.Test_new)

<a name="new_Test_new"></a>

### new Test()This is a test class

<a name="Test+name"></a>

### test.nameSet current name

**Kind**: instance property of [<code>Test</code>](#Test)
<a name="Test+name"></a>

### test.nameGet current name

**Kind**: instance property of [<code>Test</code>](#Test)
<a name="Test+generateFullName"></a>

### test.generateFullName() ⇒Generate a fullname

**Kind**: instance method of [<code>Test</code>](#Test)
**Returns**: an string
<a name="Test.Test"></a>

### Test.Test**Kind**: static class of [<code>Test</code>](#Test)
<a name="new_Test.Test_new"></a>

#### new Test([name])Creates an instance of Test.


| Param | Type | Default |
| --- | --- | --- |
| [name] | <code>string</code> | <code>&quot;&#x27;Peter&#x27;&quot;</code> |

70 changes: 70 additions & 0 deletions example/code/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
exports.fileTree=[
{
"text": "class",
"path": "/class"
},
{
"text": "methods",
"path": "/methods"
},
{
"text": "objects",
"path": "/objects"
},
{
"text": "second",
"items": []
},
{
"text": "subfolder",
"items": [
{
"text": "subfolder.1",
"items": [
{
"text": "variables",
"path": "/variables"
}
]
},
{
"text": "variables",
"path": "/variables"
}
]
}
];
exports.sidebarTree={
"/code/": [
{
"title": "API",
"collapsable": false,
"children": [
[
"",
"Mainpage"
],
[
"class",
"class"
],
[
"methods",
"methods"
],
[
"objects",
"objects"
],
[
"subfolder/subfolder.1/variables",
"subfolder/subfolder.1/variables"
],
[
"subfolder/variables",
"subfolder/variables"
]
]
}
]
};
26 changes: 26 additions & 0 deletions example/code/methods.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
title: methods
---
## Functions

<dl>
<dt><a href="#ES6Method">ES6Method()</a> ⇒</dt>
<dd><p>A normal ES6 Method</p>
</dd>
<dt><a href="#standardMethod">standardMethod()</a> ⇒</dt>
<dd><p>A normal standard Method</p>
</dd>
</dl>

<a name="ES6Method"></a>

## ES6Method() ⇒A normal ES6 Method

**Kind**: global function
**Returns**: a String
<a name="standardMethod"></a>

## standardMethod() ⇒A normal standard Method

**Kind**: global function
**Returns**: a String
35 changes: 35 additions & 0 deletions example/code/objects.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
title: objects
---
<a name="obj"></a>

## objObject description

**Kind**: global constant

* [obj](#obj)
* [.name](#obj.name)
* [.objMethod(parameter)](#obj.objMethod)
* [.objMethodTwo()](#obj.objMethodTwo)

<a name="obj.name"></a>

### obj.namename

**Kind**: static property of [<code>obj</code>](#obj)
<a name="obj.objMethod"></a>

### obj.objMethod(parameter) ⇒A function with a parameter and returns the name

**Kind**: static method of [<code>obj</code>](#obj)
**Returns**: this.name

| Param | Type |
| --- | --- |
| parameter | <code>any</code> |

<a name="obj.objMethodTwo"></a>

### obj.objMethodTwo()lkfnsdlfsdnl

**Kind**: static method of [<code>obj</code>](#obj)
29 changes: 29 additions & 0 deletions example/code/subfolder/subfolder.1/variables.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
title: variables
---
## Members

<dl>
<dt><a href="#normalLetVariable">normalLetVariable</a></dt>
<dd><p>A normal let variable</p>
</dd>
</dl>

## Constants

<dl>
<dt><a href="#MY_CONST_VAR">MY_CONST_VAR</a></dt>
<dd><p>Symbol constant</p>
</dd>
</dl>

<a name="normalLetVariable"></a>

## normalLetVariableA normal let variable

**Kind**: global variable
<a name="MY_CONST_VAR"></a>

## MY_CONST_VARSymbol constant

**Kind**: global constant
Loading

0 comments on commit b380ffe

Please sign in to comment.