Skip to content

Commit a943c94

Browse files
caio-pizzolcaiopizzolharbournick
authored
chore: add jsdocs + extension docs auto-gen (#783)
* docs: add GitHub Actions workflow to trigger documentation updates on main branch changes * chore: add ESLint configuration for JSDoc validation in documentation files * chore: update ESLint configuration for JSDoc and enhance type definitions in field annotation * chore: refine field annotation file structure and suppress TypeScript errors * docs: enhance Editor type definition in SuperDoc.js for improved clarity and structure * docs: enhance JSDoc comments for field annotation methods to improve clarity and type definitions * chore: disable checkJs in tsconfig and enable JSDoc checking in field annotation file * chore: remove redundant JSDoc type definitions in SuperDoc.js and clean up ESLint configuration * chore: remove TypeScript ignore comments from various files to improve code quality * chore: remove TypeScript ignore comments from FieldAnnotationPlugin.js to enhance code quality * chore: refactor build scripts and remove unused TypeScript type definitions in super-editor * chore: update build configuration and improve TypeScript output structure in super-editor * docs: enhance JSDoc comments and type definitions for DocumentSection in super-editor * docs: add @category Command tag to JSDoc comments in DocumentSection for better organization * docs: refine JSDoc comments and type definitions for section creation and update in DocumentSection * chore: remove outDir option from tsconfig.build.json in super-editor * chore: refactor initPagination method to private and update tsconfig formatting in super-editor * refactor: replace initPagination calls with private method #initPagination in Editor class * fix: correct syntax in catch blocks for better error handling in Editor class * Doc gen: Add aliases to tsconfig, remove ts-ignore in document sections (#798) * chore: add vite aliases to tsconfig * fix: remove ts-ignore and fix issues to ensure file builds --------- Co-authored-by: Caio Pizzol <caiopizzol@icloud.com> Co-authored-by: Nick Bernal <117235294+harbournick@users.noreply.github.com>
1 parent 83607ba commit a943c94

11 files changed

Lines changed: 334 additions & 67 deletions

File tree

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Trigger Documentation Update
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
# Trigger when extensions change
9+
- 'packages/super-editor/src/extensions/**/*.js'
10+
# - 'packages/super-editor/src/core/**/*.js'
11+
# - 'packages/super-editor/src/components/**/*.js'
12+
workflow_dispatch: # Manual trigger
13+
14+
jobs:
15+
trigger-docs:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Trigger Documentation Repository Update
19+
run: |
20+
# Set the required variables
21+
repo_owner="Harbour-Enterprises"
22+
repo_name="SuperDoc-Docs"
23+
event_type="docs-update"
24+
25+
curl -L \
26+
-X POST \
27+
-H "Accept: application/vnd.github+json" \
28+
-H "Authorization: Bearer ${{ secrets.SUPERDOC_PAT }}" \
29+
-H "X-GitHub-Api-Version: 2022-11-28" \
30+
https://api.github.com/repos/$repo_owner/$repo_name/dispatches \
31+
-d "{\"event_type\": \"$event_type\"}"
32+
33+
- name: Notify Success
34+
if: success()
35+
run: echo "✅ Documentation update triggered successfully"

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ dist-ssr
1010
.env
1111
.npmrc
1212
.eslintcache
13+
types/
1314

1415
npm-debug.log*
1516
yarn-debug.log*

eslint.config.docs.mjs

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
import jsdoc from 'eslint-plugin-jsdoc';
2+
3+
export default [
4+
{
5+
files: ['packages/super-editor/src/extensions/**/*.js'],
6+
plugins: {
7+
jsdoc
8+
},
9+
rules: {
10+
// Require minimal JSDoc for extensions
11+
'jsdoc/require-jsdoc': ['warn', {
12+
publicOnly: true,
13+
require: {
14+
FunctionDeclaration: false,
15+
MethodDefinition: false,
16+
ClassDeclaration: false,
17+
ArrowFunctionExpression: false,
18+
FunctionExpression: false
19+
},
20+
contexts: [
21+
// Document the extension module
22+
'ExportNamedDeclaration > VariableDeclaration > VariableDeclarator > CallExpression[callee.property.name="create"]'
23+
24+
// Note: We document commands/helpers with @param/@returns
25+
// inside addCommands/addHelpers, not with require-jsdoc
26+
]
27+
}],
28+
29+
// When JSDoc exists, validate it's correct
30+
'jsdoc/require-param': 'error', // All params must be documented
31+
'jsdoc/require-param-type': 'error', // @param must have {Type}
32+
'jsdoc/check-param-names': 'error', // @param names must match
33+
'jsdoc/check-types': 'error', // Valid type syntax (string not String)
34+
35+
// Optional - we use @returns {Function} or skip it
36+
'jsdoc/require-returns': 'off',
37+
'jsdoc/require-returns-type': 'off',
38+
39+
// Don't require descriptions if obvious
40+
'jsdoc/require-param-description': 'off',
41+
'jsdoc/require-returns-description': 'off',
42+
'jsdoc/require-description': 'off',
43+
44+
// Don't require examples - nice to have but not essential
45+
'jsdoc/require-example': 'off',
46+
47+
// Simple formatting
48+
'jsdoc/require-hyphen-before-param-description': 'off', // Optional: @param {Type} name - Description
49+
50+
// Allow types from our .d.ts files and common types
51+
'jsdoc/no-undefined-types': ['warn', {
52+
definedTypes: [
53+
// Allow any type that starts with capital letter (likely imported)
54+
'/^[A-Z]/',
55+
56+
// Common utility types
57+
'Partial', 'Required', 'Readonly', 'Pick', 'Omit',
58+
59+
// Built-in types
60+
'Function', 'Object', 'Array', 'Promise',
61+
62+
// DOM
63+
'HTMLElement', 'Element', 'Event'
64+
]
65+
}],
66+
67+
// Don't enforce these
68+
'jsdoc/valid-types': 'off', // We use TypeScript syntax
69+
'jsdoc/check-tag-names': 'off', // Allow @module, @typedef, etc.
70+
'jsdoc/check-alignment': 'off', // Don't worry about alignment
71+
'jsdoc/multiline-blocks': 'off' // Allow single or multi-line
72+
},
73+
settings: {
74+
jsdoc: {
75+
mode: 'typescript', // Understand TypeScript syntax in JSDoc
76+
preferredTypes: {
77+
object: 'Object', // Use Object not object
78+
array: 'Array', // Use Array not array
79+
'Array.<>': 'Array<>', // Use Array<Type> not Array.<Type>
80+
}
81+
}
82+
}
83+
}
84+
];

package-lock.json

Lines changed: 116 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
"format:check": "prettier --check \"**/*.{js,jsx,vue,css,scss,json,md}\"",
2626
"lint": "eslint",
2727
"lint:fix": "eslint --fix",
28+
"lint:jsdoc": "eslint packages/super-editor/src/extensions/field-annotation/field-annotation.js --config eslint.config.docs.mjs",
29+
"lint:jsdoc:fix": "eslint packages/super-editor/src/extensions/field-annotation/field-annotation.js --config eslint.config.docs.mjs --fix",
2830
"docs:dev": "vuepress dev docs",
2931
"docs:build": "vuepress build docs",
3032
"pack": "npm run build:super-editor && npm --prefix ./packages/superdoc run pack",
@@ -54,6 +56,7 @@
5456
"@vuepress/theme-default": "^2.0.0-rc.60",
5557
"eslint": "^9.31.0",
5658
"eslint-config-prettier": "^9.1.0",
59+
"eslint-plugin-jsdoc": "^54.1.0",
5760
"husky": "^9.1.7",
5861
"lint-staged": "^16.1.4",
5962
"prettier": "3.3.3",

packages/super-editor/package.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,13 @@
3838
"module": "./dist/super-editor.es.js",
3939
"scripts": {
4040
"dev": "vite",
41-
"preview": "vite preview",
42-
"build": "vite build && tsc",
43-
"clean": "rm -rf dist",
41+
"build": "vite build && npm run types:build",
42+
"build:watch": "vite build --watch",
43+
"types:check": "tsc --noEmit",
44+
"types:build": "tsc -p tsconfig.build.json",
4445
"test": "vitest",
45-
"build:watch": "vite build --watch --logLevel warn",
46+
"preview": "vite preview",
47+
"clean": "rm -rf dist types",
4648
"pack": "rm *.tgz 2>/dev/null || true && npm run build && npm pack && mv harbour-enterprises-super-editor-0.0.1-alpha.0.tgz ./super-editor.tgz"
4749
},
4850
"dependencies": {

0 commit comments

Comments
 (0)