-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: document vuepress-jsdoc with itself
- Loading branch information
Showing
16 changed files
with
638 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
const { sidebarTree } = require('../code/config'); | ||
|
||
module.exports = { | ||
contentLoading: true, | ||
dest: 'public', | ||
title: 'vuepress-jsdoc', | ||
description: 'vuepress-jsdoc documented with itself', | ||
plugins: [ | ||
[ | ||
// require('vuepress-jsdoc') | ||
require('../../dist/index.js').default, | ||
{ | ||
folder: 'code', | ||
jsDocConfigPath: './jsdoc.json', | ||
source: './src', | ||
dist: './documentation', | ||
title: 'API' | ||
} | ||
] | ||
], | ||
locales: { | ||
'/': { | ||
title: 'vuepress-jsdoc', | ||
description: 'A CLI to create jsdoc md files for vuepress' | ||
} | ||
}, | ||
themeConfig: { | ||
sidebarDepth: 4, | ||
locales: { | ||
'/': { | ||
nav: [ | ||
{ | ||
text: 'Home', | ||
link: '/' | ||
} | ||
], | ||
// Add the generated sidebar | ||
sidebar: { | ||
...sidebarTree('Readme') | ||
} | ||
} | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
home: true | ||
actionText: Get Started → | ||
actionLink: /code/ | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,200 @@ | ||
# vuepress-jsdoc | ||
|
||
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=ph1p_vuepress-jsdoc&metric=alert_status)](https://sonarcloud.io/dashboard?id=ph1p_vuepress-jsdoc) | ||
[![npm](https://img.shields.io/npm/v/vuepress-jsdoc.svg)](https://www.npmjs.com/package/vuepress-jsdoc) | ||
[![vercel](https://img.shields.io/badge/vercel-demo-black)](https://vuepress-jsdoc-example.vercel.app) | ||
|
||
This npm package is a command line script, which scans your JavaScript, Vue or Typescript source code and generates markdown files for vuepress with the help of [jsdoc-to-markdown](https://github.com/jsdoc2md/jsdoc-to-markdown) and [vue-docgen-cli](https://github.com/vue-styleguidist/vue-styleguidist/tree/dev/packages/vue-docgen-cli). | ||
|
||
![CLI ./example](https://user-images.githubusercontent.com/15351728/131877824-0124e47f-9080-4976-88d0-84ad04b64f24.gif) | ||
|
||
## How to | ||
|
||
```bash | ||
yarn global add vuepress-jsdoc | ||
npm i vuepress-jsdoc -g | ||
``` | ||
|
||
**Example:** | ||
|
||
```bash | ||
# search code in src and move it to code (./documentation/code) in your vuepress folder (./documentation) | ||
vuepress-jsdoc --source ./src --dist ./documentation --folder code --title API --exclude=**/*/*.test.js | ||
``` | ||
|
||
#### Plugin (Dev-Mode) `alpha` | ||
|
||
You can use `vuepress-jsdoc` also as plugin. | ||
This plugin watches you generated files. | ||
|
||
```javascript | ||
// .vuepress/config.js | ||
plugins: [ | ||
[ | ||
require('vuepress-jsdoc').default, | ||
{ | ||
folder: 'code', | ||
jsDocConfigPath: './jsdoc.json', | ||
source: './src', | ||
dist: './documentation', | ||
title: 'API' | ||
} | ||
] | ||
]; | ||
``` | ||
|
||
#### Watch-Mode `alpha` | ||
|
||
If you do not want to run`vuepress-jsdoc` again and again and again. | ||
You can simply pass `--watch` or `-w`. | ||
|
||
### Commands | ||
|
||
If no command passed it will run `generate` as default | ||
|
||
| Name | Alias | Description | | ||
| -------- | ------ | ------------------------------------------------------------------------------------------------------- | | ||
| generate | gen, g | search code in src and move it to code (./documentation/code) in your vuepress folder (./documentation) | | ||
|
||
### Options | ||
|
||
| Name | Alias | Default | Description | | ||
| ----------------- | ----- | --------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| --source | -s | ./src | Source folder with .js or .ts files | | ||
| --dist | -d | ./documentation | Destination folder | | ||
| --folder | -f | ./code | Folder inside destination folder. Gets overwritten everytime | | ||
| --title | -t | API | Title of your documentation | | ||
| --help | -h | | Show help | | ||
| --version | -v | | Show current version | | ||
| --readme | -r | | Path to custom readme file | | ||
| --exclude | -e | | Pattern to exclude files/folders (Comma seperated) - \*.test.js,exclude.js [more information](https://github.com/micromatch/micromatch#ismatch) | | ||
| --rmPattern | -rm | | Pattern when removing files. You can ex- and include files. (glob pattern) | | ||
| --partials | -p | | jsdoc2markdown partial templates (overwrites default ones) | | ||
| --jsDocConfigPath | -c | | Path to [JsDoc Config](http://usejsdoc.org/about-configuring-jsdoc.html) (experimental) | | ||
| --watch | -w | | Watch changes and update markdown files | | ||
|
||
### config.js | ||
|
||
Inside your generated folder, you can find a `config.js`. | ||
This file includes a complete filetree and an vuepress sidebar tree. | ||
|
||
## How to configure vuepress | ||
|
||
[Vuepress](https://vuepress.vuejs.org/) is a 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 | ||
yarn global add vuepress | ||
|
||
# Run the CLI | ||
vuepress-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/](http://localhost:8080/code/) | ||
|
||
Now you need the sidebar. | ||
Create a `.vuepress` folder inside the `documentation` folder and add the following `config.js`. | ||
|
||
**config.js:** | ||
|
||
```javascript | ||
// auto generated sidebar | ||
const { sidebarTree } = require('../code/config'); | ||
|
||
module.exports = { | ||
dest: 'dist', | ||
locales: { | ||
'/': { | ||
title: 'vuepress-jsdoc', | ||
description: 'Generate jsdoc markdown files for vuepress' | ||
} | ||
}, | ||
themeConfig: { | ||
editLinks: true, | ||
sidebarDepth: 4, | ||
docsDir: 'code', | ||
locales: { | ||
'/': { | ||
nav: [ | ||
{ | ||
text: 'Home', | ||
link: '/' | ||
} | ||
], | ||
// Add the generated sidebar | ||
sidebar: Object.assign({}, sidebarTree('Mainpage title')) | ||
} | ||
} | ||
} | ||
}; | ||
``` | ||
|
||
## Custom readme | ||
|
||
You can easily add a custom path to your readme by using the `--readme ./path/to/file.md` parameter. If you move a `README.md` inside your source folder, it should resolve it automatically. | ||
You can set the title by passing it to the `sidebarTree('Mainpage title')` function inside your `./.vuepress/config.js`. | ||
|
||
Once the README.md has been added, it is no longer overwritten! | ||
If you want it to be overwritten, set `--rmPattern=./documentation/code/README.md`. | ||
|
||
## @vuepress comment block | ||
|
||
You can add custom meta data to your pages by using the `@vuepress` block: | ||
|
||
```javascript | ||
/* | ||
* @vuepress | ||
* --- | ||
* title: Your custom title | ||
* headline: You custom headline | ||
* --- | ||
*/ | ||
``` | ||
|
||
Use `headline` to add a custom `h1` title. | ||
|
||
[More information](https://vuepress.vuejs.org/guide/markdown.html#front-matter) | ||
|
||
## Typescript | ||
|
||
To use typescript, you have to install these dev-dependencies: | ||
|
||
```bash | ||
yarn add -D typescript jsdoc-babel @babel/cli @babel/core @babel/preset-env @babel/preset-typescript jsdoc-to-markdown | ||
``` | ||
|
||
Next, you have to add a `jsdoc.json` to your project with some settings and add it with the `-c` parameter. | ||
You can find a full working example with all settings inside the `./example` folder. | ||
The example shows also how to use babel-`plugins`. | ||
|
||
## Example | ||
|
||
The `./example` folder includes a full working vuepress-jsdoc example. | ||
|
||
```bash | ||
# Install dependencies | ||
npm install | ||
|
||
# Run the CLI | ||
vuepress-jsdoc | ||
|
||
# Generate docs | ||
npm run docs | ||
|
||
# Run dev server | ||
npm run dev | ||
|
||
# Generate dist folder | ||
npm run build | ||
``` | ||
|
||
## Contribute | ||
|
||
PRs are always welcome (: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
--- | ||
title: Main | ||
headline: The Main File | ||
--- | ||
|
||
# The Main File | ||
|
||
## Functions | ||
|
||
<dl> | ||
<dt><a href="#createVuepressSidebar">createVuepressSidebar(options)</a> ⇒</dt> | ||
<dd><p>Create the sidebar</p> | ||
</dd> | ||
<dt><a href="#parseDirectoryFile">parseDirectoryFile(file, argv)</a> ⇒</dt> | ||
<dd><p>Parse file</p> | ||
</dd> | ||
<dt><a href="#parseArguments">parseArguments(argv)</a> ⇒</dt> | ||
<dd><p>Parse all CLI arguments</p> | ||
</dd> | ||
<dt><a href="#generate">generate(argv)</a></dt> | ||
<dd><p>Default command that generate md files</p> | ||
</dd> | ||
<dt><a href="#plugin">plugin(argv, ctx)</a> ⇒</dt> | ||
<dd><p>The vuepress plugins</p> | ||
</dd> | ||
</dl> | ||
|
||
<a name="createVuepressSidebar"></a> | ||
|
||
## createVuepressSidebar(options) ⇒ | ||
Create the sidebar | ||
|
||
**Kind**: global function | ||
**Returns**: Promise | ||
|
||
| Param | | ||
| --- | | ||
| options | | ||
|
||
<a name="parseDirectoryFile"></a> | ||
|
||
## parseDirectoryFile(file, argv) ⇒ | ||
Parse file | ||
|
||
**Kind**: global function | ||
**Returns**: Promise | ||
|
||
| Param | | ||
| --- | | ||
| file | | ||
| argv | | ||
|
||
<a name="parseArguments"></a> | ||
|
||
## parseArguments(argv) ⇒ | ||
Parse all CLI arguments | ||
|
||
**Kind**: global function | ||
**Returns**: all arguments | ||
|
||
| Param | | ||
| --- | | ||
| argv | | ||
|
||
<a name="generate"></a> | ||
|
||
## generate(argv) | ||
Default command that generate md files | ||
|
||
**Kind**: global function | ||
|
||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| argv | <code>object</code> | passed arguments | | ||
|
||
<a name="plugin"></a> | ||
|
||
## plugin(argv, ctx) ⇒ | ||
The vuepress plugins | ||
|
||
**Kind**: global function | ||
**Returns**: plugin | ||
|
||
| Param | | ||
| --- | | ||
| argv | | ||
| ctx | | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
--- | ||
title: comment-parser | ||
--- | ||
|
||
# comment-parser | ||
|
||
## Functions | ||
|
||
<dl> | ||
<dt><a href="#parseComment">parseComment(fileContent)</a> ⇒</dt> | ||
<dd><p>Search in file for @vuepress comment</p> | ||
</dd> | ||
<dt><a href="#parseVuepressFileHeader">parseVuepressFileHeader(content, file)</a> ⇒</dt> | ||
<dd><p>Helper function to get header as strctured markdown</p> | ||
</dd> | ||
</dl> | ||
|
||
<a name="parseComment"></a> | ||
|
||
## parseComment(fileContent) ⇒ | ||
Search in file for @vuepress comment | ||
|
||
**Kind**: global function | ||
**Returns**: object of found frontmatter data | ||
|
||
| Param | | ||
| --- | | ||
| fileContent | | ||
|
||
<a name="parseVuepressFileHeader"></a> | ||
|
||
## parseVuepressFileHeader(content, file) ⇒ | ||
Helper function to get header as strctured markdown | ||
|
||
**Kind**: global function | ||
**Returns**: markdown header | ||
|
||
| Param | Description | | ||
| --- | --- | | ||
| content | : ; | | ||
| file | | | ||
|
Oops, something went wrong.