1 | # vuepress-jsdoc
|
2 |
|
3 | [![Codacy Badge](https://api.codacy.com/project/badge/Grade/9ec565a85a134df2a0f6bdf905e438d4)](https://app.codacy.com/app/ph1p/vuepress-jsdoc?utm_source=github.com&utm_medium=referral&utm_content=ph1p/vuepress-jsdoc&utm_campaign=Badge_Grade_Settings)
|
4 | [![npm](https://img.shields.io/npm/v/vuepress-jsdoc.svg)](https://www.npmjs.com/package/vuepress-jsdoc)
|
5 | [![now](https://img.shields.io/badge/now-demo-black)](https://vuepress-jsdoc-example.now.sh)
|
6 |
|
7 | 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-api](https://github.com/vue-styleguidist/vue-styleguidist/tree/dev/packages/vue-docgen-api).
|
8 |
|
9 | ![CLI ./example](/example/img/cli.gif)
|
10 |
|
11 | ## How to
|
12 |
|
13 | ```bash
|
14 | yarn global add vuepress-jsdoc
|
15 | npm i vuepress-jsdoc -g
|
16 | ```
|
17 |
|
18 | **Example:**
|
19 |
|
20 | ```bash
|
21 | # search code in src and move it to code (./documentation/code) in your vuepress folder (./documentation)
|
22 | vuepress-jsdoc --source ./src --dist ./documentation --folder code --title API --exclude *.test.js,exclude.js
|
23 | ```
|
24 |
|
25 | ### Commands
|
26 |
|
27 | If no command passed it will run `generate` as default
|
28 |
|
29 | | Name | Alias | Description |
|
30 | | -------- | ------ | ------------------------------------------------------------------------------------------------------- |
|
31 | | generate | gen, g | search code in src and move it to code (./documentation/code) in your vuepress folder (./documentation) |
|
32 |
|
33 | ### Options
|
34 |
|
35 | | Name | Alias | Default | Description |
|
36 | | ----------------- | ----- | --------------- | --------------------------------------------------------------------------------------- |
|
37 | | --source | -s | ./src | Source folder with .js or .ts files |
|
38 | | --dist | -d | ./documentation | Destination folder |
|
39 | | --folder | -f | ./code | Folder inside destination folder. Gets overwritten everytime |
|
40 | | --title | -t | API | Title of your documentation |
|
41 | | --help | -h | | Show help |
|
42 | | --version | -v | | Show current version |
|
43 | | --readme | -r | | Path to custom readme file |
|
44 | | --exclude | -e | | Pattern to exclude files/folders (Comma seperated) - \*.test.js,exclude.js |
|
45 | | --rmPattern | -rm | | Pattern when removing files. You can ex- and include files. (glob pattern) |
|
46 | | --jsDocConfigPath | -c | | Path to [JsDoc Config](http://usejsdoc.org/about-configuring-jsdoc.html) (experimental) |
|
47 |
|
48 | ### config.js
|
49 |
|
50 | Inside your generated folder, you can find a `config.js`.
|
51 | This file includes a complete filetree and an vuepress sidebar tree.
|
52 |
|
53 | ## How to configure vuepress
|
54 |
|
55 | [Vuepress](https://vuepress.vuejs.org/) is a static site generator by Evan You.
|
56 | You can add all generated documentation files to your existing vuepress project or create a new one.
|
57 |
|
58 | ```bash
|
59 | # First install vuepress
|
60 | yarn global add vuepress
|
61 |
|
62 | # Run the CLI
|
63 | vuepress-jsdoc
|
64 |
|
65 | # Run vuepress dev server
|
66 | vuepress dev ./documentation
|
67 |
|
68 | # Run vuepress build, if you want to ship it
|
69 | vuepress build ./documentation
|
70 | ```
|
71 |
|
72 | **Access it via:** [http://localhost:8080/code/](http://localhost:8080/code/)
|
73 |
|
74 | Now you need the sidebar.
|
75 | Create a `.vuepress` folder inside the `documentation` folder and add the following `config.js`.
|
76 |
|
77 | **config.js:**
|
78 |
|
79 | ```javascript
|
80 | // auto generated sidebar
|
81 | const { sidebarTree } = require("../code/config");
|
82 |
|
83 | module.exports = {
|
84 | dest: "dist",
|
85 | locales: {
|
86 | "/": {
|
87 | title: "vuepress-jsdoc",
|
88 | description: "Generate jsdoc markdown files for vuepress"
|
89 | }
|
90 | },
|
91 | themeConfig: {
|
92 | editLinks: true,
|
93 | sidebarDepth: 4,
|
94 | docsDir: "code",
|
95 | locales: {
|
96 | "/": {
|
97 | nav: [
|
98 | {
|
99 | text: "Home",
|
100 | link: "/"
|
101 | }
|
102 | ],
|
103 | // Add the generated sidebar
|
104 | sidebar: Object.assign({}, sidebarTree("Mainpage title"))
|
105 | }
|
106 | }
|
107 | }
|
108 | };
|
109 | ```
|
110 |
|
111 | ## Custom readme
|
112 |
|
113 | 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.
|
114 | You can set the title by passing it to the `sidebarTree('Mainpage title')` function inside your `./.vuepress/config.js`.
|
115 |
|
116 | Once the README.md has been added, it is no longer overwritten!
|
117 | If you want it to be overwritten, set `--rmPattern=./documentation/code/README.md`.
|
118 |
|
119 | ## @vuepress comment block
|
120 |
|
121 | You can add custom meta data your pages by using the `@vuepress` block:
|
122 |
|
123 | ```javascript
|
124 | /*
|
125 | * @vuepress
|
126 | * ---
|
127 | * title: Your custom title
|
128 | * headline: You custom headline
|
129 | * ---
|
130 | */
|
131 | ```
|
132 |
|
133 | Use `headline` to add a custom `h1` title.
|
134 |
|
135 | [More information](https://vuepress.vuejs.org/guide/markdown.html#front-matter)
|
136 |
|
137 | ## Example
|
138 |
|
139 | The `./example` folder includes a full working vuepress-jsdoc example.
|
140 |
|
141 | ```bash
|
142 | # Install dependencies
|
143 | yarn
|
144 |
|
145 | # Run the CLI
|
146 | vuepress-jsdoc
|
147 |
|
148 | # Generate docs
|
149 | yarn docs
|
150 |
|
151 | # Run dev server
|
152 | yarn dev
|
153 |
|
154 | # Generate dist folder
|
155 | yarn build
|
156 | ```
|
157 |
|
158 | ## Contribute
|
159 |
|
160 | PRs are always welcome (: |
\ | No newline at end of file |