@qubit-ltd/jsdoc-theme 1.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +260 -0
- package/LICENSE +21 -0
- package/README.md +798 -0
- package/clean-jsdoc-theme-defaults.js +37 -0
- package/clean-jsdoc-theme-helper.js +186 -0
- package/helpers/Environment.html +3 -0
- package/helpers/down-arrow.js +9 -0
- package/helpers/i18n.js +106 -0
- package/i18n/en.json +76 -0
- package/i18n/zh.json +76 -0
- package/package.json +83 -0
- package/publish.js +1133 -0
- package/static/fonts/Inconsolata-Regular.ttf +0 -0
- package/static/fonts/OpenSans-Regular.ttf +0 -0
- package/static/fonts/WorkSans-Bold.ttf +0 -0
- package/static/scripts/core.js +720 -0
- package/static/scripts/core.min.js +23 -0
- package/static/scripts/resize.js +90 -0
- package/static/scripts/search.js +269 -0
- package/static/scripts/search.min.js +6 -0
- package/static/scripts/third-party/Apache-License-2.0.txt +202 -0
- package/static/scripts/third-party/fuse.js +1749 -0
- package/static/scripts/third-party/hljs-line-num-original.js +367 -0
- package/static/scripts/third-party/hljs-line-num.js +1 -0
- package/static/scripts/third-party/hljs-original.js +5260 -0
- package/static/scripts/third-party/hljs.js +1 -0
- package/static/scripts/third-party/popper.js +1287 -0
- package/static/scripts/third-party/tippy.js +1499 -0
- package/static/scripts/third-party/tocbot.js +757 -0
- package/static/scripts/third-party/tocbot.min.js +1 -0
- package/static/styles/clean-jsdoc-theme-base.css +1257 -0
- package/static/styles/clean-jsdoc-theme-dark.css +412 -0
- package/static/styles/clean-jsdoc-theme-light.css +482 -0
- package/static/styles/clean-jsdoc-theme-scrollbar.css +30 -0
- package/static/styles/clean-jsdoc-theme-without-scrollbar.min.css +1 -0
- package/static/styles/clean-jsdoc-theme.min.css +1 -0
- package/tmpl/augments.tmpl +10 -0
- package/tmpl/container.tmpl +261 -0
- package/tmpl/details.tmpl +207 -0
- package/tmpl/example.tmpl +3 -0
- package/tmpl/examples.tmpl +48 -0
- package/tmpl/exceptions.tmpl +32 -0
- package/tmpl/i18n-tooltips.tmpl +30 -0
- package/tmpl/icons.tmpl +77 -0
- package/tmpl/include-target-script-and-styles.tmpl +43 -0
- package/tmpl/layout.tmpl +169 -0
- package/tmpl/mainpage.tmpl +10 -0
- package/tmpl/members.tmpl +42 -0
- package/tmpl/method.tmpl +190 -0
- package/tmpl/mobile-sidebar.tmpl +21 -0
- package/tmpl/navbar-actions.tmpl +25 -0
- package/tmpl/navbar-menu.tmpl +25 -0
- package/tmpl/navbar.tmpl +14 -0
- package/tmpl/params.tmpl +131 -0
- package/tmpl/properties.tmpl +109 -0
- package/tmpl/returns.tmpl +19 -0
- package/tmpl/search.tmpl +17 -0
- package/tmpl/sidebar-items.tmpl +33 -0
- package/tmpl/sidebar-title.tmpl +8 -0
- package/tmpl/sidebar.tmpl +9 -0
- package/tmpl/source.tmpl +13 -0
- package/tmpl/toc.tmpl +4 -0
- package/tmpl/tutorial.tmpl +32 -0
- package/tmpl/type.tmpl +13 -0
package/README.md
ADDED
|
@@ -0,0 +1,798 @@
|
|
|
1
|
+
# qubit-jsdoc-theme
|
|
2
|
+
|
|
3
|
+
[](https://github.com/Haixing-Hu/qubit-jsdoc-theme) [](https://github.com/Haixing-Hu/qubit-jsdoc-theme/fork)  [](https://github.com/Haixing-Hu/qubit-jsdoc-theme/issues) [](https://github.com/Haixing-Hu/qubit-jsdoc-theme/graphs/contributors) [](https://github.com/Haixing-Hu/qubit-jsdoc-theme/blob/master/LICENSE)
|
|
4
|
+
<br>
|
|
5
|
+
|
|
6
|
+
**Based on [clean-jsdoc-theme](https://github.com/ankitskvmdam/clean-jsdoc-theme) v4.3.0**
|
|
7
|
+
|
|
8
|
+
`qubit-jsdoc-theme` is a customized version of the popular `clean-jsdoc-theme` that enhances your JSDoc 3 or 4 documentation with additional features specifically designed for better class documentation. It maintains all the beautiful and responsive design features of the original theme while adding enhanced property documentation capabilities.
|
|
9
|
+
|
|
10
|
+
## Enhanced Features (New in qubit-jsdoc-theme)
|
|
11
|
+
|
|
12
|
+
- **🆕 Smart Properties Table:** Automatically generates a dedicated "Properties" section for classes, displaying all class properties in a clean table format with type information and descriptions derived from individual field JSDoc comments.
|
|
13
|
+
- **🆕 Intelligent Constructor Detection:** Only displays the "Constructor" section when a class has explicit constructor documentation, avoiding empty constructor sections for classes without custom constructors.
|
|
14
|
+
- **🆕 Field-Level JSDoc Support:** Properties table is populated directly from `@type` annotations on individual class fields, eliminating the need for redundant `@property` tags in class-level JSDoc.
|
|
15
|
+
- **🆕 Clean Member Organization:** Properties are displayed in their own dedicated section, while the "Members" section can be configured to show only methods, avoiding duplication.
|
|
16
|
+
- **🆕 Internationalization (i18n):** Full support for multiple languages with comprehensive translation of all UI elements, section headings, table headers, and navigation tooltips.
|
|
17
|
+
- **🆕 Homepage Navigation:** Added a "Back to Homepage" button in the top navigation bar for easy navigation between class documentation and the main documentation index.
|
|
18
|
+
- **🆕 Enhanced Tooltips:** All navigation buttons include internationalized tooltips that adapt to the selected language.
|
|
19
|
+
|
|
20
|
+
## Key Features (Inherited from clean-jsdoc-theme)
|
|
21
|
+
|
|
22
|
+
- **Widespread Device Compatibility:** Adapts seamlessly to desktops, laptops, tablets, and mobile devices, ensuring a smooth user experience across all platforms.
|
|
23
|
+
- **Premium Aesthetics:** Choose between a sleek dark theme or a bright light theme, both designed to deliver a high-quality appearance for your documentation.
|
|
24
|
+
- **Optimized File Size:** Automatically minifies the generated HTML files, reducing their overall size by several kilobytes without compromising functionality.
|
|
25
|
+
- **Robust Search Functionality:** The built-in search feature allows users to quickly find specific information within your documentation, and it does so without adding extra weight to the output files.
|
|
26
|
+
- **Exceptional Performance:** Prioritizes performance, delivering a fast and responsive user experience for your documentation consumers.
|
|
27
|
+
- **Extensive Customization:** Offers a wide variety of customization options to tailor the look and feel to your preferences.
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
## Demo
|
|
31
|
+
|
|
32
|
+
The enhanced features of `qubit-jsdoc-theme` include:
|
|
33
|
+
|
|
34
|
+
1. **Smart Properties Table**: Automatically generated from field-level `@type` annotations
|
|
35
|
+
2. **Intelligent Constructor Detection**: Only shows constructor section when explicitly documented
|
|
36
|
+
3. **Clean Organization**: Properties and methods are clearly separated
|
|
37
|
+
|
|
38
|
+
For the base theme features and styling, you can reference the original [clean-jsdoc-theme demo](https://ankdev.me/clean-jsdoc-theme/v4).
|
|
39
|
+
|
|
40
|
+
## Screenshots
|
|
41
|
+
|
|
42
|
+

|
|
43
|
+

|
|
44
|
+

|
|
45
|
+

|
|
46
|
+

|
|
47
|
+

|
|
48
|
+
|
|
49
|
+
## Installation
|
|
50
|
+
|
|
51
|
+
> Note : you must have `node` and `npm` installed on your machine.
|
|
52
|
+
|
|
53
|
+
In a terminal, type :
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
npm install @qubit-ltd/jsdoc-theme --save-dev
|
|
57
|
+
# or
|
|
58
|
+
yarn add @qubit-ltd/jsdoc-theme -D
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
In your projects `package.json` file, add a script to generate the documentation using JSDoc :
|
|
62
|
+
|
|
63
|
+
```json
|
|
64
|
+
"scripts": {
|
|
65
|
+
"generate-docs": "jsdoc --configure jsdoc.json --verbose"
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
> Heads Up! In the above `generate_docs` script, the value of the `--configure` option is `jsdoc.json`. Make sure
|
|
70
|
+
> the `jsdoc.json` file exists as it contains the JSDoc configuration. If you have your JSDoc config in a different
|
|
71
|
+
> file,
|
|
72
|
+
> replace `jsdoc.json` with its name.
|
|
73
|
+
|
|
74
|
+
In your `jsdoc.json` file, add a template option to use `qubit-jsdoc-theme` instead of the default JSDoc theme:
|
|
75
|
+
|
|
76
|
+
```json
|
|
77
|
+
"opts": {
|
|
78
|
+
"template": "node_modules/@qubit-ltd/jsdoc-theme"
|
|
79
|
+
}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Now, run the previously added script to generate the documentation :
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
npm run generate-docs
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Usage Example
|
|
89
|
+
|
|
90
|
+
Here's how to document your JavaScript classes to take advantage of the enhanced features:
|
|
91
|
+
|
|
92
|
+
```javascript
|
|
93
|
+
/**
|
|
94
|
+
* Represents a user in the system.
|
|
95
|
+
* @class User
|
|
96
|
+
* @author John Doe
|
|
97
|
+
*/
|
|
98
|
+
class User {
|
|
99
|
+
/**
|
|
100
|
+
* User's unique identifier
|
|
101
|
+
* @type {string}
|
|
102
|
+
*/
|
|
103
|
+
id;
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* User's display name
|
|
107
|
+
* @type {string}
|
|
108
|
+
*/
|
|
109
|
+
name;
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* User's email address
|
|
113
|
+
* @type {string}
|
|
114
|
+
*/
|
|
115
|
+
email;
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Whether the user is active
|
|
119
|
+
* @type {boolean}
|
|
120
|
+
*/
|
|
121
|
+
isActive;
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Creates a new user instance
|
|
125
|
+
* @param {string} name - The user's name
|
|
126
|
+
* @param {string} email - The user's email
|
|
127
|
+
*/
|
|
128
|
+
constructor(name, email) {
|
|
129
|
+
this.name = name;
|
|
130
|
+
this.email = email;
|
|
131
|
+
this.isActive = true;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Activates the user account
|
|
136
|
+
* @returns {boolean} True if activation was successful
|
|
137
|
+
*/
|
|
138
|
+
activate() {
|
|
139
|
+
this.isActive = true;
|
|
140
|
+
return true;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
This will generate documentation with:
|
|
146
|
+
- A dedicated "Properties" section showing all class properties in a table
|
|
147
|
+
- A "Constructor" section (only if constructor has documentation)
|
|
148
|
+
- A "Members" section for methods (properties are excluded to avoid duplication)
|
|
149
|
+
|
|
150
|
+
## Example JSDoc Config
|
|
151
|
+
|
|
152
|
+
```json
|
|
153
|
+
{
|
|
154
|
+
"source": {
|
|
155
|
+
"include": ["lib", "package.json", "README.md"],
|
|
156
|
+
"includePattern": ".js$",
|
|
157
|
+
"excludePattern": "(node_modules/|docs)"
|
|
158
|
+
},
|
|
159
|
+
"plugins": ["plugins/markdown"],
|
|
160
|
+
"opts": {
|
|
161
|
+
"encoding": "utf8",
|
|
162
|
+
"readme": "./README.md",
|
|
163
|
+
"destination": "docs/",
|
|
164
|
+
"recurse": true,
|
|
165
|
+
"verbose": true,
|
|
166
|
+
"template": "./node_modules/@qubit-ltd/jsdoc-theme",
|
|
167
|
+
"theme_opts": {
|
|
168
|
+
"default_theme": "dark",
|
|
169
|
+
"language": "en"
|
|
170
|
+
}
|
|
171
|
+
},
|
|
172
|
+
"markdown": {
|
|
173
|
+
"hardwrap": false,
|
|
174
|
+
"idInHeadings": true
|
|
175
|
+
// This is important for clean-jsdoc-theme, otherwise some features might not work.
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
## Options
|
|
181
|
+
|
|
182
|
+
### Set a default theme
|
|
183
|
+
|
|
184
|
+
To set the default theme, add the following in your JSDoc config file:
|
|
185
|
+
|
|
186
|
+
```json
|
|
187
|
+
"theme_opts": {
|
|
188
|
+
"default_theme": "dark" // "light", "fallback-dark", "fallback-light"
|
|
189
|
+
}
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
If you set default theme as `"fallback-dark"`, then `clean-jsdoc-theme` will try to detect user's preferred color scheme. If it will detect successfully then it will set user's preferred theme else fallback to dark theme.
|
|
193
|
+
|
|
194
|
+
### Set language (i18n)
|
|
195
|
+
|
|
196
|
+
To set the documentation language, add the following in your JSDoc config file:
|
|
197
|
+
|
|
198
|
+
```json
|
|
199
|
+
"theme_opts": {
|
|
200
|
+
"language": "en" // "en" for English, "zh" for Chinese
|
|
201
|
+
}
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
**Supported languages:**
|
|
205
|
+
- `"en"` - English (default)
|
|
206
|
+
- `"zh"` - Chinese (中文)
|
|
207
|
+
|
|
208
|
+
**The language setting affects:**
|
|
209
|
+
- Section headings (Properties, Methods, Constructor, etc.)
|
|
210
|
+
- Table headers (Name, Type, Description, etc.)
|
|
211
|
+
- Navigation button tooltips (Back to Homepage, Toggle Theme, Search, Change Font Size)
|
|
212
|
+
- Parameter attributes (optional, nullable, repeatable, Properties)
|
|
213
|
+
- Method documentation labels (Parameters, Returns, Type, Fires, Throws, etc.)
|
|
214
|
+
- Detail information labels (Author, Version, Since, Inherited From, etc.)
|
|
215
|
+
|
|
216
|
+
If no language is specified, English will be used as the default.
|
|
217
|
+
|
|
218
|
+
**Adding new languages:**
|
|
219
|
+
|
|
220
|
+
To add support for a new language, you need to:
|
|
221
|
+
|
|
222
|
+
1. Create a new translation file in the `i18n/` directory (e.g., `i18n/fr.json` for French)
|
|
223
|
+
2. Copy the structure from `i18n/en.json` and translate all values
|
|
224
|
+
3. The translation file should include all keys with their translated values:
|
|
225
|
+
|
|
226
|
+
```json
|
|
227
|
+
{
|
|
228
|
+
"properties": "Propriétés",
|
|
229
|
+
"methods": "Méthodes",
|
|
230
|
+
"constructor": "Constructeur",
|
|
231
|
+
"name": "Nom",
|
|
232
|
+
"type": "Type",
|
|
233
|
+
"description": "Description",
|
|
234
|
+
"home_tooltip": "Retour à l'accueil",
|
|
235
|
+
"toggle_theme_tooltip": "Basculer le thème",
|
|
236
|
+
"search_tooltip": "Rechercher",
|
|
237
|
+
"font_size_tooltip": "Changer la taille de police",
|
|
238
|
+
// ... add all other keys from en.json
|
|
239
|
+
}
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
4. The i18n system will automatically load the appropriate language file based on the `language` setting in your JSDoc configuration.
|
|
243
|
+
|
|
244
|
+
### Set base url
|
|
245
|
+
|
|
246
|
+
To set the base url, add the following in your JSDoc config file:
|
|
247
|
+
|
|
248
|
+
```json
|
|
249
|
+
"theme_opts": {
|
|
250
|
+
"base_url": "https://ankdev.me/v4/"
|
|
251
|
+
}
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
> Make sure to add a forward slash (`/`) at the end of the URL.
|
|
255
|
+
|
|
256
|
+
The default value of `base_url` is computed with the following code:
|
|
257
|
+
|
|
258
|
+
```js
|
|
259
|
+
const path = document.location.pathname;
|
|
260
|
+
const baseURL = path.substr(0, path.lastIndexOf('/') + 1);
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
### Add favicon
|
|
264
|
+
|
|
265
|
+
To set a favicon, add the following in your JSDoc config file:
|
|
266
|
+
|
|
267
|
+
```json
|
|
268
|
+
"theme_opts": {
|
|
269
|
+
"favicon": "path/to/img"
|
|
270
|
+
}
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
You can use [`static_dir`](#add-static-dir) option to copy all you static files to output dir and use that path instead
|
|
274
|
+
of `path/to/img`. This will not flatten the output file path, it will preserve the directory structure. If you want to
|
|
275
|
+
flatten the output dir use jsdoc default [copy static files options](https://jsdoc.app/about-configuring-default-template.html)
|
|
276
|
+
|
|
277
|
+
### Add homepage title
|
|
278
|
+
|
|
279
|
+
To add the title of the homepage use the `homepageTitle` property as follows:
|
|
280
|
+
|
|
281
|
+
```json
|
|
282
|
+
"theme_opts": {
|
|
283
|
+
"homepageTitle": "Clean JSDoc theme"
|
|
284
|
+
}
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
### Add title
|
|
288
|
+
|
|
289
|
+
Both strings and HTML are accepted. Use HTML to overwrite the default HTML, and a string to set a plaintext title. One
|
|
290
|
+
example of this is below:
|
|
291
|
+
|
|
292
|
+
```json
|
|
293
|
+
"theme_opts": {
|
|
294
|
+
"title": "<img src='path/to/img' class='my-custom-class'/>" // or "title": "clean-jsodc-theme"
|
|
295
|
+
}
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
You can use [`static_dir`](#add-static-dir) option to copy all you static files to output dir and use that path in place
|
|
299
|
+
of `path/to/img`.
|
|
300
|
+
|
|
301
|
+
### Add files list in homepage
|
|
302
|
+
|
|
303
|
+
By default `clean-jsdoc-theme` will not include the list of files in the homepage. If you want to add them the do the following
|
|
304
|
+
|
|
305
|
+
```json
|
|
306
|
+
"theme_opts": {
|
|
307
|
+
"includeFilesListInHomepage": true // by default it is false.
|
|
308
|
+
}
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
> Note: You need to add @file tag in the .js if you want to include it in the file list. For more details on `@file` visit: https://jsdoc.app/tags-file.html
|
|
312
|
+
|
|
313
|
+
### Add navbar menu
|
|
314
|
+
|
|
315
|
+
To render extra link(s) in navbar. It accepts an array of objects:
|
|
316
|
+
|
|
317
|
+
```json
|
|
318
|
+
"theme_opts": {
|
|
319
|
+
"menu": [
|
|
320
|
+
{
|
|
321
|
+
"title": "Website",
|
|
322
|
+
"link": "https://ankdev.me/clean-jsdoc-theme/dark/",
|
|
323
|
+
"target": "_blank",
|
|
324
|
+
"class": "some-class",
|
|
325
|
+
"id": "some-id"
|
|
326
|
+
},
|
|
327
|
+
{
|
|
328
|
+
// more if you want to.
|
|
329
|
+
}
|
|
330
|
+
]
|
|
331
|
+
}
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
`menu` is an array of objects. Each object has five properties, out of which two are required (`title` and `link`). If
|
|
335
|
+
an object doesn't have the required properties, then you might expect an error.
|
|
336
|
+
|
|
337
|
+
<b>Properties</b>
|
|
338
|
+
|
|
339
|
+
| name | type | required |
|
|
340
|
+
| -------- | -------- | -------- |
|
|
341
|
+
| `title` | `string` | required |
|
|
342
|
+
| `link` | `string` | required |
|
|
343
|
+
| `target` | `string` | optional |
|
|
344
|
+
| `class` | `string` | optional |
|
|
345
|
+
| `id` | `string` | optional |
|
|
346
|
+
|
|
347
|
+
### Sections
|
|
348
|
+
|
|
349
|
+
There is also an option to add a meta tag to every generated HTML file. You can use the `meta` option to include a list
|
|
350
|
+
of `meta` tags into `head`.
|
|
351
|
+
|
|
352
|
+
```json
|
|
353
|
+
"theme_opts": {
|
|
354
|
+
"sections": ["Classes", "Modules", "Global"] // Only three members will be in the sidebar.
|
|
355
|
+
}
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
```js
|
|
359
|
+
// SECTION_TYPE
|
|
360
|
+
[
|
|
361
|
+
'Classes',
|
|
362
|
+
'Modules',
|
|
363
|
+
'Externals',
|
|
364
|
+
'Events',
|
|
365
|
+
'Namespaces',
|
|
366
|
+
'Mixins',
|
|
367
|
+
'Tutorials',
|
|
368
|
+
'Interfaces',
|
|
369
|
+
'Global',
|
|
370
|
+
];
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
### Meta
|
|
374
|
+
|
|
375
|
+
There is also an option to add meta tag to every generated HTML file. You can use `meta` option to include a list
|
|
376
|
+
of `meta` tags into `head`.
|
|
377
|
+
|
|
378
|
+
```json
|
|
379
|
+
"theme_opts": {
|
|
380
|
+
"meta": [
|
|
381
|
+
{
|
|
382
|
+
"name": "author",
|
|
383
|
+
"content": "Ankit Kumar"
|
|
384
|
+
},
|
|
385
|
+
{
|
|
386
|
+
"name": "description",
|
|
387
|
+
"content": "Best Clean and minimal JSDoc 3 Template/Theme"
|
|
388
|
+
}
|
|
389
|
+
]
|
|
390
|
+
}
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
`meta` is an array of objects. Each objects can have any valid combination
|
|
394
|
+
of [HTML metadata attributes](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta#Attributes).
|
|
395
|
+
|
|
396
|
+
### Search
|
|
397
|
+
|
|
398
|
+
By default, the search feature is enabled in the theme.
|
|
399
|
+
|
|
400
|
+
> Make sure you have added the `base_url` option as well, otherwise your search query might fail.
|
|
401
|
+
>
|
|
402
|
+
> If you want to disable the search feature, you can do the following:
|
|
403
|
+
|
|
404
|
+
```json
|
|
405
|
+
"theme_opts": {
|
|
406
|
+
"search": false
|
|
407
|
+
}
|
|
408
|
+
```
|
|
409
|
+
|
|
410
|
+
**How does the search work?**
|
|
411
|
+
|
|
412
|
+
If the search feature is enabled, you'll see a `data` folder in the output. This `data` folder contains a JSON
|
|
413
|
+
called `search.json`. There is a fetch request when user types anything in the search box. That means search data is
|
|
414
|
+
only loaded if user wants to search anything.
|
|
415
|
+
|
|
416
|
+
### CodePen
|
|
417
|
+
|
|
418
|
+
> Note: currently, this feature is only enabled for the examples section.
|
|
419
|
+
|
|
420
|
+
```json
|
|
421
|
+
"theme_opts": {
|
|
422
|
+
"codepen": {
|
|
423
|
+
"enable_for": ["examples"],
|
|
424
|
+
"options": {
|
|
425
|
+
"js_external": "https://code.jquery.com/jquery-3.6.0.min.js",
|
|
426
|
+
"js_pre_processor": "babel"
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
```
|
|
431
|
+
|
|
432
|
+
`options` can be any valid CodePen option. For more
|
|
433
|
+
visit: [Codepen Prefill options](https://blog.codepen.io/documentation/prefill/#all-the-json-options-0)
|
|
434
|
+
|
|
435
|
+
If you want to add some js in the beginning of your example then you can use `js` option.
|
|
436
|
+
|
|
437
|
+
```json
|
|
438
|
+
"theme_opts": {
|
|
439
|
+
"codepen": {
|
|
440
|
+
"enable_for": ["examples"],
|
|
441
|
+
"options": {
|
|
442
|
+
"js_external": "https://code.jquery.com/jquery-3.6.0.min.js",
|
|
443
|
+
"js_pre_processor": "babel"
|
|
444
|
+
"js": "import Something from 'some-package'"
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
```
|
|
449
|
+
|
|
450
|
+
Let say you have an example as follows:
|
|
451
|
+
|
|
452
|
+
```js
|
|
453
|
+
/**
|
|
454
|
+
* @example
|
|
455
|
+
* let a = Something.fn()
|
|
456
|
+
* console.log(a) // Return value of something
|
|
457
|
+
*/
|
|
458
|
+
const a;
|
|
459
|
+
```
|
|
460
|
+
|
|
461
|
+
In codepen the above `@example` will look like:
|
|
462
|
+
|
|
463
|
+
```js
|
|
464
|
+
import Something from 'some-package';
|
|
465
|
+
|
|
466
|
+
let a = Something.fn();
|
|
467
|
+
console.log(a); // Return value of something
|
|
468
|
+
```
|
|
469
|
+
|
|
470
|
+
### Add static dir
|
|
471
|
+
|
|
472
|
+
To include static files:
|
|
473
|
+
|
|
474
|
+
```json
|
|
475
|
+
"theme_opts": {
|
|
476
|
+
"static_dir": ["./static"],
|
|
477
|
+
}
|
|
478
|
+
```
|
|
479
|
+
|
|
480
|
+
### Add styles
|
|
481
|
+
|
|
482
|
+
To create custom style rules. Example:
|
|
483
|
+
|
|
484
|
+
```json
|
|
485
|
+
"theme_opts": {
|
|
486
|
+
"create_style": ".sidebar-title { font-size: 2rem }"
|
|
487
|
+
}
|
|
488
|
+
```
|
|
489
|
+
|
|
490
|
+
### Add style paths
|
|
491
|
+
|
|
492
|
+
Use this option to add third party css library. If you want to add your own custom css file then consider
|
|
493
|
+
using [Add custom css files](#add-custom-css-files)
|
|
494
|
+
|
|
495
|
+
> Note: you have to pass an array of objects. Each object key will be an attribute inside the generated style tag.
|
|
496
|
+
|
|
497
|
+
Example:
|
|
498
|
+
|
|
499
|
+
```json
|
|
500
|
+
"add_style_path": [
|
|
501
|
+
{
|
|
502
|
+
"href": "https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta1/dist/css/bootstrap.min.css",
|
|
503
|
+
"integrity": "sha384-giJF6kkoqNQ00vy+HMDP7azOuL0xtbfIcaT9wjKHr8RbDVddVHyTfAAsrekwKmP1",
|
|
504
|
+
"crossorigin": "anonymous"
|
|
505
|
+
}
|
|
506
|
+
],
|
|
507
|
+
```
|
|
508
|
+
|
|
509
|
+
### Add custom css files
|
|
510
|
+
|
|
511
|
+
To include css files. Example:
|
|
512
|
+
|
|
513
|
+
```json
|
|
514
|
+
"theme_opts": {
|
|
515
|
+
"include_css": ["./static/index.css", "./src/docs/index.css"]
|
|
516
|
+
}
|
|
517
|
+
```
|
|
518
|
+
|
|
519
|
+
> Note: you are not required to manually copy file to output dir.
|
|
520
|
+
|
|
521
|
+
It will include the css files to the output dir and also attach a link tag to the html pointing to the included css
|
|
522
|
+
file.
|
|
523
|
+
|
|
524
|
+
### Add scripts
|
|
525
|
+
|
|
526
|
+
If you wish to incorporate JavaScript functions that execute when a user accesses a webpage, you can utilize the add_scripts option for this purpose. For instance, suppose you want to display a notification dialog when a user visits the webpage located at https://place-where-my-docs-are/SomeClass.html. You want to notify users that they should refrain from utilizing this class. To accomplish this, you can proceed as follows:
|
|
527
|
+
|
|
528
|
+
```json
|
|
529
|
+
"theme_opts": {
|
|
530
|
+
"add_scripts": "function showAlert(){ if (window.location.pathname === '/SomeClass.html') { alert('Do not use this class') } } showAlert();",
|
|
531
|
+
}
|
|
532
|
+
```
|
|
533
|
+
|
|
534
|
+
Writing js code like above can get tricky and complex. You can consider `include_js`.
|
|
535
|
+
|
|
536
|
+
### Add script paths
|
|
537
|
+
|
|
538
|
+
Use this option to add third party js library. If you want to add your own custom script file then consider
|
|
539
|
+
using [Add custom script files](#add-custom-script-files)
|
|
540
|
+
|
|
541
|
+
> Note: you have to pass an array of objects, and object keys are actually the attributes which you want in you script
|
|
542
|
+
> tag.
|
|
543
|
+
|
|
544
|
+
Example:
|
|
545
|
+
|
|
546
|
+
```json
|
|
547
|
+
"add_script_path": [
|
|
548
|
+
{
|
|
549
|
+
"href": "https://code.jquery.com/jquery-3.5.1.js",
|
|
550
|
+
"integrity": "sha256-QWo7LDvxbWT2tbbQ97B53yJnYU3WhH/C8ycbRAkjPDc=",
|
|
551
|
+
"crossorigin": "anonymous"
|
|
552
|
+
}
|
|
553
|
+
],
|
|
554
|
+
```
|
|
555
|
+
|
|
556
|
+
This will copy the static folder to the output dir.
|
|
557
|
+
|
|
558
|
+
> Note: if the directory doesn't exist then you may get an error. Also, directory is relative to your jsdoc config file.
|
|
559
|
+
|
|
560
|
+
This will not flatten the directory. Directory structure will be kept as it is.
|
|
561
|
+
|
|
562
|
+
### Add custom script files
|
|
563
|
+
|
|
564
|
+
If you wish to run some local/custom javascript then you can include them via `include_js`.
|
|
565
|
+
|
|
566
|
+
Lets say you want to show some custom message depending on url. You can create a js file as follows:
|
|
567
|
+
|
|
568
|
+
```js
|
|
569
|
+
// static/showAlert.js
|
|
570
|
+
function showCustomAlertMessage() {
|
|
571
|
+
const pathname = window.location.pathname;
|
|
572
|
+
|
|
573
|
+
switch (pathname) {
|
|
574
|
+
case '/SomeClass.html':
|
|
575
|
+
return alert("Please don't use this class");
|
|
576
|
+
case '/OtherPage.html':
|
|
577
|
+
return alert('Wonderful!');
|
|
578
|
+
default:
|
|
579
|
+
return;
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
showCustomAlert();
|
|
584
|
+
```
|
|
585
|
+
|
|
586
|
+
Assuming the above js file is stored in `./static/showAlert.js`. To include you can do:
|
|
587
|
+
|
|
588
|
+
```json
|
|
589
|
+
"theme_opts": {
|
|
590
|
+
"include_js": ["./static/showAlert.js"]
|
|
591
|
+
}
|
|
592
|
+
```
|
|
593
|
+
|
|
594
|
+
> Note: you are not required to manually copy file to output dir.
|
|
595
|
+
|
|
596
|
+
It will include the js files to the output dir and also attach a script tag to the html pointing to the included js
|
|
597
|
+
file.
|
|
598
|
+
|
|
599
|
+
If you want to add some script for some pages then you can do the following:
|
|
600
|
+
|
|
601
|
+
```json
|
|
602
|
+
"include_js": [
|
|
603
|
+
"./demo/src/assets/script.js",
|
|
604
|
+
{
|
|
605
|
+
"filepath": "./demo/src/assets/random.js",
|
|
606
|
+
"targets": [
|
|
607
|
+
"MyClass",
|
|
608
|
+
"tutorial-MyClassTutorial"
|
|
609
|
+
]
|
|
610
|
+
}
|
|
611
|
+
],
|
|
612
|
+
```
|
|
613
|
+
|
|
614
|
+
Here target is the name of the generated html file (don't include `.html`).
|
|
615
|
+
|
|
616
|
+
The above config will add `./demo/src/assets/script.js` to all the generated html files. However, it will
|
|
617
|
+
add `./demo/src/assets/random.js` only to `MyClass.html` and `tutorial-MyClassTutorial.html` files.
|
|
618
|
+
|
|
619
|
+
The file name of the generated html generally follows the following convention:
|
|
620
|
+
|
|
621
|
+
- Class: class's name + `.html`. Ex `Alive.html`
|
|
622
|
+
- Module: `module-` + module's name + `.html`. Ex: `module-SqlJs.html`
|
|
623
|
+
- Tutorials: `tutorial-` + tutorial's filename + `.html`
|
|
624
|
+
|
|
625
|
+
If you are not sure about the target name, then generate html for the first time, then look at the urls.
|
|
626
|
+
|
|
627
|
+
### To ignore sorting
|
|
628
|
+
|
|
629
|
+
To ignore the sorting of members/methods/event in the page. If it is `false` then the order of
|
|
630
|
+
members/methods/events will be in the order they are in code/source.
|
|
631
|
+
|
|
632
|
+
```json
|
|
633
|
+
"theme_opts": {
|
|
634
|
+
"sort": false
|
|
635
|
+
}
|
|
636
|
+
```
|
|
637
|
+
|
|
638
|
+
### Footer
|
|
639
|
+
|
|
640
|
+
```json
|
|
641
|
+
"theme_opts": {
|
|
642
|
+
"footer": "This is footer" // or <div class="footer-wrapper">This is a footer </div>
|
|
643
|
+
}
|
|
644
|
+
```
|
|
645
|
+
|
|
646
|
+
### To exclude inherited
|
|
647
|
+
|
|
648
|
+
To exclude inherited symbols. Example:
|
|
649
|
+
|
|
650
|
+
```json
|
|
651
|
+
"exclude_inherited": true
|
|
652
|
+
```
|
|
653
|
+
|
|
654
|
+
This will remove all symbols (members, methods ...) that come from inherited parents.
|
|
655
|
+
|
|
656
|
+
### To remove styled applied to scrollbar
|
|
657
|
+
|
|
658
|
+
By default `clean-jsdoc-theme` applies some styles to browser's scroll bar. However if you want to remove this style do the following
|
|
659
|
+
|
|
660
|
+
```json
|
|
661
|
+
{
|
|
662
|
+
"theme_opts": {
|
|
663
|
+
"shouldRemoveScrollbarStyle": false
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
```
|
|
667
|
+
|
|
668
|
+
This will remove all symbols (members, methods ...) that come from inherited parents.
|
|
669
|
+
|
|
670
|
+
## Cheat sheet
|
|
671
|
+
|
|
672
|
+
| name | default | use case | expected value(s) |
|
|
673
|
+
| ---------------------------- | ------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------- | ---------------------------------------------------------- |
|
|
674
|
+
| `default_theme` | `"dark"` | To set the default theme | `"light", "dark"`, `"fallback-light"` or `"fallback-dark"` |
|
|
675
|
+
| `language` | `"en"` | To set the documentation language (i18n) | `"en"` (English) or `"zh"` (Chinese) |
|
|
676
|
+
| `homepageTitle` | "Home" | To set the title of homepage. This will update HTML `<title>`. | `string` |
|
|
677
|
+
| `title` | `null` | To set the title of the sidebar. | `HTML` or `string` |
|
|
678
|
+
| `base_url` | `/` | To set the base URL | `string` |
|
|
679
|
+
| `menu` | `null` | To render extra link in navbar | Array of Object(s) |
|
|
680
|
+
| `meta` | `null` | Meta tag attributes | Array of Object(s) |
|
|
681
|
+
| `search` | `true` | To render search or not | `true` or `false` |
|
|
682
|
+
| `codepen` | `{}` | To open code in codepen | `Object` |
|
|
683
|
+
| `static_dir` | `null` | To include static dir | Array of string |
|
|
684
|
+
| `create_style` | `null` | To create custom style rules | `string` |
|
|
685
|
+
| `add_style_path` | `null` | To add external css libraries/files | Array of Object(s) |
|
|
686
|
+
| `include_css` | `null` | To include css files | Array of string |
|
|
687
|
+
| `add_scripts` | `null` | To create custom script | `string` |
|
|
688
|
+
| `add_script_path` | `null` | To add external js libraries/files | Array of Object(s) |
|
|
689
|
+
| `include_js` | `null` | To include js files | `string` |
|
|
690
|
+
| `footer` | `null` | To render footer | `HTML` or `string` |
|
|
691
|
+
| `exclude_inherited` | `false` | To exclude inherited symbols | `boolean` |
|
|
692
|
+
| `sections` | `["Modules", "Classes", "Externals", "Events", "Namespaces", "Mixins", "Tutorials", "Interfaces", "Global"]` | To order navbar/sidebar sections or to hide/remove navbar/sidebar sections | `Array<SECTION_TYPE>` |
|
|
693
|
+
| `displayModuleHeader` | `false` | If you want the module name to appear on its page | `boolean` |
|
|
694
|
+
| `includeFilesListInHomepage` | `false` | If you want to add or remove the list of files in homepage | `boolean` |
|
|
695
|
+
| `sort` | `true` | To sort the output members/methods/events | `boolean` |
|
|
696
|
+
| `shouldRemoveScrollbarStyle` | `false` | To remove styles applied to browser's scrollbar | `boolean` |
|
|
697
|
+
|
|
698
|
+
Don't forget to add the following in your jsdoc config file, otherwise toc will not work on some pages.
|
|
699
|
+
|
|
700
|
+
```json
|
|
701
|
+
"markdown": {
|
|
702
|
+
"idInHeadings": true // This is important for clean-jsdoc-theme, otherwise some features might not work.
|
|
703
|
+
}
|
|
704
|
+
```
|
|
705
|
+
|
|
706
|
+
## Changelog
|
|
707
|
+
|
|
708
|
+
### v1.2.0 (2025-01-XX)
|
|
709
|
+
|
|
710
|
+
**Major Update - Internationalization & Navigation Enhancements**
|
|
711
|
+
|
|
712
|
+
#### 🌍 New Features
|
|
713
|
+
- **Full Internationalization (i18n)**: Complete support for multiple languages with comprehensive translation system
|
|
714
|
+
- **Homepage Navigation Button**: Added "Back to Homepage" button in top navigation bar for easy navigation
|
|
715
|
+
- **Internationalized Tooltips**: All navigation buttons now include language-aware tooltips
|
|
716
|
+
- **Enhanced Language Support**: Built-in support for English and Chinese with easy extensibility for additional languages
|
|
717
|
+
|
|
718
|
+
#### 🔧 Technical Improvements
|
|
719
|
+
- **i18n System Architecture**: Implemented robust internationalization system with helper functions and language files
|
|
720
|
+
- **Template Enhancements**: Updated all template files to support dynamic language switching
|
|
721
|
+
- **Smart Language Detection**: Automatic language file loading based on JSDoc configuration
|
|
722
|
+
- **Tooltip Integration**: Enhanced tooltip system with i18n support using tippy.js
|
|
723
|
+
|
|
724
|
+
#### 📝 Documentation Updates
|
|
725
|
+
- **Comprehensive i18n Guide**: Detailed instructions for configuring languages and adding new translations
|
|
726
|
+
- **Usage Examples**: Updated examples to show i18n configuration
|
|
727
|
+
- **Developer Guide**: Instructions for extending language support
|
|
728
|
+
|
|
729
|
+
### v1.0.0 (2025-01-XX)
|
|
730
|
+
|
|
731
|
+
**Initial Release - Based on clean-jsdoc-theme v4.3.0**
|
|
732
|
+
|
|
733
|
+
#### 🆕 New Features
|
|
734
|
+
- **Smart Properties Table**: Automatically generates a dedicated "Properties" section for classes
|
|
735
|
+
- **Field-Level JSDoc Support**: Properties table populated from individual field `@type` annotations
|
|
736
|
+
- **Intelligent Constructor Detection**: Only displays constructor section when explicitly documented
|
|
737
|
+
- **Clean Member Organization**: Properties displayed separately from methods to avoid duplication
|
|
738
|
+
- **English Comments**: All custom code uses English comments for better universality
|
|
739
|
+
|
|
740
|
+
#### 🔧 Technical Changes
|
|
741
|
+
- Custom template modifications in `container.tmpl` and `method.tmpl`
|
|
742
|
+
- Enhanced property collection and rendering logic
|
|
743
|
+
- Smart constructor detection algorithm
|
|
744
|
+
- Template-only solution (no custom plugins required)
|
|
745
|
+
|
|
746
|
+
#### 📦 Package Updates
|
|
747
|
+
- Package name: `@qubit-ltd/jsdoc-theme`
|
|
748
|
+
- Updated build pipeline for production deployment
|
|
749
|
+
- Configured for Qubit private npm registry
|
|
750
|
+
|
|
751
|
+
For the base theme changelog, see [clean-jsdoc-theme changelog](https://github.com/ankitskvmdam/clean-jsdoc-theme/blob/master/CHANGELOG.md).
|
|
752
|
+
|
|
753
|
+
## Developing
|
|
754
|
+
|
|
755
|
+
```bash
|
|
756
|
+
git clone https://github.com/Haixing-Hu/qubit-jsdoc-theme.git
|
|
757
|
+
cd qubit-jsdoc-theme
|
|
758
|
+
npm install
|
|
759
|
+
npm install jsdoc --no-save
|
|
760
|
+
npm run build
|
|
761
|
+
```
|
|
762
|
+
|
|
763
|
+
`npm run build` will generate minified CSS and JavaScript files for production use.
|
|
764
|
+
|
|
765
|
+
To test your changes:
|
|
766
|
+
```bash
|
|
767
|
+
npm run build:demo
|
|
768
|
+
```
|
|
769
|
+
|
|
770
|
+
This will generate demo documentation in the `output` folder.
|
|
771
|
+
|
|
772
|
+
## Contributing
|
|
773
|
+
|
|
774
|
+
We welcome contributions! Please feel free to submit issues and pull requests on [GitHub](https://github.com/Haixing-Hu/qubit-jsdoc-theme).
|
|
775
|
+
|
|
776
|
+
## Acknowledgments
|
|
777
|
+
|
|
778
|
+
This project is based on the excellent [clean-jsdoc-theme](https://github.com/ankitskvmdam/clean-jsdoc-theme) by [Ankit Kumar](https://github.com/ankitskvmdam). We extend our gratitude to the original author and all contributors of the clean-jsdoc-theme project.
|
|
779
|
+
|
|
780
|
+
## Contributors
|
|
781
|
+
|
|
782
|
+
<a href="https://github.com/Haixing-Hu/qubit-jsdoc-theme/graphs/contributors">
|
|
783
|
+
<img src="https://contrib.rocks/image?repo=Haixing-Hu/qubit-jsdoc-theme" alt="qubit-jsdoc-theme-contributors" />
|
|
784
|
+
</a>
|
|
785
|
+
|
|
786
|
+
## Thanks
|
|
787
|
+
|
|
788
|
+
Thanks to [fuse.js](https://fusejs.io/), [hljs](https://highlightjs.org/), [tippy.js](https://tippyjs.bootcss.com/), the original [clean-jsdoc-theme](https://github.com/ankitskvmdam/clean-jsdoc-theme) project, and all awesome contributors.
|
|
789
|
+
|
|
790
|
+
## Contact
|
|
791
|
+
|
|
792
|
+
If you like this project, please give it a <a href="https://github.com/Haixing-Hu/qubit-jsdoc-theme" data-icon="octicon-star" aria-label="Star Haixing-Hu/qubit-jsdoc-theme on GitHub">star</a>.
|
|
793
|
+
|
|
794
|
+
Mail: <a href="mailto:starfish.hu@gmail.com">starfish.hu@gmail.com</a> <br>
|
|
795
|
+
|
|
796
|
+
## License
|
|
797
|
+
|
|
798
|
+
Licensed under the MIT license.
|