1 | # The vuedoc Markdown Documentation Generator
|
2 | Generate a Markdown Documentation for a Vue file
|
3 |
|
4 | [![Build Status](https://travis-ci.org/vuedoc/md.svg?branch=master)](https://travis-ci.org/vuedoc/md) [![Coverage Status](https://coveralls.io/repos/github/vuedoc/md/badge.svg?branch=master)](https://coveralls.io/github/vuedoc/md?branch=master)
|
5 |
|
6 | ## Install
|
7 | ```sh
|
8 | # using in your project
|
9 | npm install --save @vuedoc/md
|
10 |
|
11 | # using in command line
|
12 | npm install --global @vuedoc/md
|
13 | ```
|
14 |
|
15 | ## Features
|
16 | - Generate documentation for component props
|
17 | - Generate documentation for component data
|
18 | - Generate documentation for computed properties with their dependencies
|
19 | - Generate documentation for component events
|
20 | - Generate documentation for component slots
|
21 | - Generate documentation for component methods
|
22 |
|
23 | ## Usage
|
24 |
|
25 | First use comments to document your component (see [test/fixtures/checkbox.vue](https://github.com/vuedoc/md/blob/develop/test/fixtures/checkbox.vue) for a complete example):
|
26 |
|
27 | ```vue
|
28 | <template>
|
29 | <div>
|
30 | <!-- Use this slot to set the label -->
|
31 | <label :for="id"><slot name="label"></slot></label>
|
32 | <textarea :id="id" @keyup="keyup" @input="input">
|
33 | <!-- Use this slot to set the devault value -->
|
34 | <slot></slot></textarea>
|
35 | </div>
|
36 | </template>
|
37 |
|
38 | <script>
|
39 | import _ from 'lodash'
|
40 |
|
41 | /**
|
42 | * The custom HTML `<textarea>` component.
|
43 | *
|
44 | * @author Sébastien
|
45 | * @license MIT
|
46 | */
|
47 | export default {
|
48 | name: 'my-textarea',
|
49 | props: {
|
50 | /**
|
51 | * Use this directive to create two-way data bindings with the component.
|
52 | * It automatically picks the correct way to update the element based on the input type.
|
53 | * @model
|
54 | */
|
55 | value: { type: String },
|
56 | /**
|
57 | * Defines a unique identifier (ID) which must be unique in the whole document.
|
58 | */
|
59 | id: { type: String, required: true },
|
60 | /**
|
61 | * This Boolean property indicates that the user cannot interact with the control.
|
62 | */
|
63 | disable: { type: Boolean, default: false }
|
64 | },
|
65 | methods: {
|
66 | /**
|
67 | * Define if the control value is empty of not.
|
68 | */
|
69 | isEmpty () {
|
70 | return !this.value || this.value.length === 0
|
71 | },
|
72 | /**
|
73 | * @private
|
74 | */
|
75 | input (e) {
|
76 | this.value = e.target.value
|
77 |
|
78 | /**
|
79 | * Fired when the value is changed.
|
80 | */
|
81 | this.$emit('input', this.value)
|
82 | },
|
83 | /**
|
84 | * @private
|
85 | */
|
86 | keyup (e) {
|
87 | /**
|
88 | * Fired when a key is released.
|
89 | */
|
90 | this.$emit('keyup')
|
91 | }
|
92 | }
|
93 | }
|
94 | </script>
|
95 | ```
|
96 |
|
97 | Then use the CLI to generate the documentation:
|
98 |
|
99 | ```sh
|
100 | # display the vuedoc.md version
|
101 | vuedoc.md --version
|
102 |
|
103 | # this print documentation in the standard output
|
104 | vuedoc.md components/textarea.vue
|
105 |
|
106 | # generate a Markdown documentation in a file docs/textarea.md
|
107 | vuedoc.md components/textarea.vue --output docs/
|
108 |
|
109 | # generate a Markdown documentation all components
|
110 | vuedoc.md components/*.vue --output docs/
|
111 |
|
112 | # update the API section of README.md with generated documentation
|
113 | vuedoc.md components/textarea.vue --section "API" --output README.md
|
114 |
|
115 | # comone generated documentations of all components into one
|
116 | vuedoc.md --join components/*.vue --output README.md
|
117 |
|
118 | # using pipe
|
119 | cat components/textarea.vue | vuedoc.md
|
120 | ```
|
121 |
|
122 | Output:
|
123 |
|
124 | ```md
|
125 | # my-textarea
|
126 | The custom HTML `<textarea>` component.
|
127 |
|
128 | - **author** - Sébastien
|
129 | - **license** - MIT
|
130 |
|
131 | ## props
|
132 | - `v-model` ***String*** (*optional*)
|
133 | Use this directive to create two-way data bindings with the component. It automatically picks the correct way to update the element based on the input type.
|
134 |
|
135 | - `id` ***String*** (*required*)
|
136 | Defines a unique identifier (ID) which must be unique in the whole document.
|
137 |
|
138 | - `disable` ***Boolean*** (*optional*) `default: false`
|
139 | This Boolean property indicates that the user cannot interact with the control.
|
140 |
|
141 | ## slots
|
142 | - `label` Use this slot to set the label
|
143 |
|
144 | - `default` Use this slot to set the devault value
|
145 |
|
146 | ## events
|
147 | - `input` Fired when the value is changed.
|
148 |
|
149 | - `keyup` Fired when a key is released.
|
150 |
|
151 | ## methods
|
152 | - `isEmpty()`
|
153 | Define if the control value is empty of not.
|
154 | ```
|
155 |
|
156 | ## Command line options
|
157 | ```
|
158 | --join - Combine generated documentation for multiple component files into only one
|
159 | --level [integer] - Set the title level. An integer betwen 1 and 6
|
160 | --output [file or dir] - The output directory. If absent, the STDOUT will be used
|
161 | --section [section name] - Inject the generated documentation to a section. Works with `--output file`
|
162 | --ignore-name - Ignore the component name on parsing
|
163 | --ignore-description - Ignore the component description on parsing
|
164 | --ignore-keywords - Ignore the component keywords on parsing
|
165 | --ignore-slots - Ignore the component slots on parsing
|
166 | --ignore-props - Ignore the component props on parsing
|
167 | --ignore-computed - Ignore the component computed properties on parsing
|
168 | --ignore-data - Ignore the component data on parsing
|
169 | --ignore-methods - Ignore the component methods on parsing
|
170 | --ignore-events - Ignore the component events on parsing
|
171 | ```
|
172 |
|
173 | ## Programmatic Usage
|
174 |
|
175 | **Options**
|
176 |
|
177 | | name | type | description |
|
178 | |---------|---------|------------------------------------------------------------------------------------------------------------|
|
179 | | level | integer | Set the title level. An integer betwen 1 and 6 |
|
180 | | output | string | The output of the documentation. Can be a directory or a Markdown file. If absent, the STDOUT will be used |
|
181 | | section | string | Inject the generated documentation to a section. Works with `options.output` as Markdown file output |
|
182 | | join | boolean | Combine generated documentation for multiple component files into only one |
|
183 |
|
184 | For parsing options please read the [@vuedoc/parser documentation](https://github.com/vuedoc/parser#options)
|
185 |
|
186 | **Usage**
|
187 | ```js
|
188 | const vuedoc = require('@vuedoc/md')
|
189 | const options = {
|
190 | filename: 'test/fixtures/checkbox.vue'
|
191 | }
|
192 |
|
193 | vuedoc.md(options)
|
194 | .then((document) => console.log(document))
|
195 | .catch((err) => console.error(err))
|
196 | ```
|
197 |
|
198 | ## Visibility Keywords
|
199 | - `@public` By default all commented members are public; this mean they will be part of the documented members.
|
200 | - `@protected` Commented members with this will be ignored.
|
201 | - `@private` Commented members with this will be ignored.
|
202 |
|
203 | ## Examples
|
204 | `vuedoc.md` has been used to generate documentation of bellow components:
|
205 | - `vx-input`: [https://github.com/vx-components/textarea](https://github.com/vx-components/input)
|
206 | - `vx-checkbox`: [https://github.com/vx-components/textarea](https://github.com/vx-components/checkbox)
|
207 | - `vx-textarea`: [https://github.com/vx-components/textarea](https://github.com/vx-components/textarea)
|
208 | - `vue-json-schema`: [https://github.com/demsking/vue-json-schema](https://github.com/demsking/vue-json-schema)
|
209 |
|
210 | ## Related projects
|
211 | - `jsdoc-vuedoc`: [https://github.com/ccqgithub/jsdoc-vuedoc](https://github.com/ccqgithub/jsdoc-vuedoc)
|
212 |
|
213 | ## License
|
214 | Under the MIT license. See [LICENSE](https://github.com/vuedoc/md/blob/master/LICENSE) file for more details.
|