@gesslar/bedoc 1.0.0

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.
@@ -0,0 +1,125 @@
1
+ # Contributing to BeDoc
2
+
3
+ Thank you for considering contributing to BeDoc! This document outlines the process and guidelines for contributing to the project. Please read it carefully before making any changes or submitting pull requests.
4
+
5
+ ---
6
+
7
+ ## Table of Contents
8
+
9
+ - [Code of Conduct](#code-of-conduct)
10
+ - [How Can I Contribute?](#how-can-i-contribute)
11
+ - [Reporting Issues](#reporting-issues)
12
+ - [Feature Requests](#feature-requests)
13
+ - [Submitting Code Changes](#submitting-code-changes)
14
+ - [Development Guidelines](#development-guidelines)
15
+ - [Code Style](#code-style)
16
+ - [Commit Messages](#commit-messages)
17
+ - [Pull Requests](#pull-requests)
18
+ - [Setting Up Your Environment](#setting-up-your-environment)
19
+
20
+ ---
21
+
22
+ ## Code of Conduct
23
+
24
+ All contributors must adhere to the [Contributor Covenant Code of Conduct](https://www.contributor-covenant.org/). Respect and professionalism are expected in all interactions.
25
+
26
+ ---
27
+
28
+ ## How Can I Contribute?
29
+
30
+ ### Reporting Issues
31
+
32
+ If you find a bug or something isn’t working as expected:
33
+
34
+ 1. Check the [issues](https://github.com/gesslar/BeDoc/issues) to ensure it hasn’t already been reported.
35
+ 2. Open a new issue with:
36
+ - A clear title.
37
+ - A detailed description of the problem.
38
+ - Steps to reproduce the issue.
39
+ - Relevant logs or screenshots (if applicable).
40
+
41
+ ### Feature Requests
42
+
43
+ Have an idea for a new feature? Create an issue with:
44
+
45
+ - A description of the feature.
46
+ - Why it would be useful.
47
+ - Potential challenges or considerations.
48
+
49
+ ### Submitting Code Changes
50
+
51
+ We welcome code contributions! Before submitting a pull request:
52
+
53
+ 1. Fork the repository.
54
+ 2. Create a feature branch (`git checkout -b feature/your-feature-name`).
55
+ 3. Ensure all changes adhere to the [Code Style](#code-style).
56
+ 4. Add tests for your changes if applicable.
57
+ 5. Commit your changes with a [good commit message](#commit-messages).
58
+ 6. Push your branch and open a pull request.
59
+
60
+ ---
61
+
62
+ ## Development Guidelines
63
+
64
+ ### Code Style
65
+
66
+ BeDoc enforces strict style rules. Please ensure your code adheres to the following:
67
+
68
+ - Use **ESLint** with the provided flat configuration.
69
+ - Formatting rules include:
70
+ - Insert final newlines.
71
+ - Trim trailing whitespace.
72
+ - Use `\n` for line endings.
73
+ - JavaScript files are formatted using **ESLint**.
74
+ - XML files are formatted using **Red Hat XML Formatter**.
75
+
76
+ Make sure to enable auto-formatting on save in your editor. Project-specific VS Code settings are available in `.vscode/settings.json`.
77
+
78
+ ### Commit Messages
79
+
80
+ Follow this structure for commit messages:
81
+
82
+ - **Type**: `feat`, `fix`, `docs`, `refactor`, `test`, `chore`, etc.
83
+ - **Scope**: A short scope or module name (e.g., `parser`, `hooks`).
84
+ - **Message**: A concise summary of the change.
85
+
86
+ Example:
87
+
88
+ ```
89
+ feat(parser): add support for async hooks
90
+ ```
91
+
92
+ ### Pull Requests
93
+
94
+ - Reference related issues in the description (e.g., `Closes #123`).
95
+ - Provide a summary of the changes and why they’re needed.
96
+ - Ensure all checks pass (e.g., linting, tests).
97
+ - Keep pull requests focused; avoid unrelated changes.
98
+
99
+ ---
100
+
101
+ ## Setting Up Your Environment
102
+
103
+ 1. Clone the repository:
104
+
105
+ ```bash
106
+ git clone https://github.com/gesslar/BeDoc.git
107
+ ```
108
+
109
+ 2. Install dependencies:
110
+
111
+ ```bash
112
+ npm install
113
+ ```
114
+
115
+ 3. Use the following tools:
116
+
117
+ - **Node.js** (v18 or later).
118
+ - **ESLint** for linting.
119
+ - Your preferred editor (VS Code recommended).
120
+
121
+ 4. Use the provided VS Code settings in `.vscode/settings.json` for consistent formatting.
122
+
123
+ ---
124
+
125
+ Thank you for contributing to BeDoc! Your efforts make this project better for everyone.
package/LICENSE ADDED
@@ -0,0 +1,24 @@
1
+ This is free and unencumbered software released into the public domain.
2
+
3
+ Anyone is free to copy, modify, publish, use, compile, sell, or
4
+ distribute this software, either in source code form or as a compiled
5
+ binary, for any purpose, commercial or non-commercial, and by any
6
+ means.
7
+
8
+ In jurisdictions that recognize copyright laws, the author or authors
9
+ of this software dedicate any and all copyright interest in the
10
+ software to the public domain. We make this dedication for the benefit
11
+ of the public at large and to the detriment of our heirs and
12
+ successors. We intend this dedication to be an overt act of
13
+ relinquishment in perpetuity of all present and future rights to this
14
+ software under copyright law.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
+ OTHER DEALINGS IN THE SOFTWARE.
23
+
24
+ For more information, please refer to <https://unlicense.org>
package/README.md ADDED
@@ -0,0 +1,93 @@
1
+ # BeDoc
2
+
3
+ [![CodeQL Advanced](https://github.com/gesslar/BeDoc/actions/workflows/codeql.yml/badge.svg)](https://github.com/gesslar/BeDoc/actions/workflows/codeql.yml)
4
+ [![Dependabot Updates](https://github.com/gesslar/BeDoc/actions/workflows/dependabot/dependabot-updates/badge.svg)](https://github.com/gesslar/BeDoc/actions/workflows/dependabot/dependabot-updates)
5
+ [![Auto PR and Merge - dev 🤗](https://github.com/gesslar/BeDoc/actions/workflows/autopr-dev.yml/badge.svg?branch=dev)](https://github.com/gesslar/BeDoc/actions/workflows/autopr-dev.yml)
6
+
7
+
8
+ # BeDoc
9
+
10
+ **BeDoc** is a powerful, pluggable documentation generator designed to handle any programming language and output format. With its extensible framework, you can easily create custom parsers and printers to generate structured documentation for your projects.
11
+
12
+ ---
13
+
14
+ ## Key Features
15
+
16
+ - **Pluggable Design**: BeDoc works seamlessly with custom parsers and printers
17
+ to fit your unique needs. BeDoc also supports async operations, allowing for
18
+ efficient handling of large projects.
19
+ - **Customizable Input**: Accommodate any text input, whether it’s a well-known
20
+ language like LPC or Lua, or an underserved format needing attention.
21
+ - **Async Hooks**: Take advantage of BeDoc's powerful ability to use async
22
+ hooks to modify content in-flight, providing dynamic customization during the
23
+ documentation generation process.
24
+ - **Versatile Output**: Generate documentation in formats like Markdown,
25
+ Wikitext, and more.
26
+ - **Configurable**: Supports JSON-based configuration for seamless
27
+ customization.
28
+ - **Integrated Workflow**: Use the CLI for smooth integration into your
29
+ development environment.
30
+
31
+ ---
32
+
33
+ ## Installation
34
+
35
+ Install BeDoc globally using NPM:
36
+
37
+ ```bash
38
+ npm install -g bedoc
39
+ ```
40
+
41
+ Or add it to your project as a dependency:
42
+
43
+ ```bash
44
+ npm install bedoc
45
+ ```
46
+
47
+ ---
48
+
49
+ ## Quick Start
50
+
51
+ Here’s how to use BeDoc programmatically:
52
+
53
+ ```javascript
54
+ const BeDoc = require('bedoc');
55
+
56
+ // Initialize BeDoc with your configuration
57
+ const docGenerator = new BeDoc({
58
+ input: './src',
59
+ output: './docs',
60
+ format: 'markdown',
61
+ });
62
+
63
+ // Generate documentation
64
+ (async () => {
65
+ try {
66
+ await docGenerator.generate();
67
+ console.log('Documentation generated successfully!');
68
+ } catch (error) {
69
+ console.error('Error generating documentation:', error);
70
+ }
71
+ })();
72
+ ```
73
+
74
+ For detailed usage instructions and examples, visit the website:
75
+ 👉 **[BeDoc Documentation](https://bedoc.gesslar.dev/)**
76
+
77
+ ---
78
+
79
+ ## Contributing
80
+
81
+ Contributions are welcome! Feel free to open an issue or submit a pull request.
82
+
83
+ ---
84
+
85
+ ## License
86
+
87
+ This project is licensed under the [Unlicense](./LICENSE).
88
+
89
+ ---
90
+
91
+ **Get started with BeDoc today and simplify your documentation workflow!**
92
+
93
+ _Do not taunt Happy Fun Ball._
package/package.json ADDED
@@ -0,0 +1,64 @@
1
+ {
2
+ "name": "@gesslar/bedoc",
3
+ "version": "1.0.0",
4
+ "description": "Pluggable documentation engine for any language and format",
5
+ "publisher": "gesslar",
6
+ "main": "./src/core/Core.js",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/gesslar/BeDoc.git"
10
+ },
11
+ "bugs": {
12
+ "url": "https://github.com/gesslar/BeDoc/issues"
13
+ },
14
+ "bin": {
15
+ "bedoc": "src/cli.js"
16
+ },
17
+ "type": "module",
18
+ "scripts": {
19
+ "lint:check": "npx eslint .",
20
+ "lint:fix": "npx eslint . --fix"
21
+ },
22
+ "dependencies": {
23
+ "commander": "^13.0.0",
24
+ "dotenv": "^16.4.7",
25
+ "error-stack-parser": "^2.1.4",
26
+ "eslint-plugin-jsdoc": "^50.6.2",
27
+ "globby": "^14.0.2",
28
+ "micromatch": "^4.0.8",
29
+ "node-fetch": "^3.3.2",
30
+ "vscode-uri": "^3.0.8",
31
+ "yaml": "^2.7.0"
32
+ },
33
+ "devDependencies": {
34
+ "@stylistic/eslint-plugin-js": "^2.13.0",
35
+ "axios": "^1.7.9",
36
+ "chokidar": "^4.0.3",
37
+ "eslint": "^9.18.0",
38
+ "form-data": "^4.0.1"
39
+ },
40
+ "keywords": [
41
+ "documentation",
42
+ "plugin",
43
+ "parser",
44
+ "printer",
45
+ "generator",
46
+ "language",
47
+ "format",
48
+ "hooks"
49
+ ],
50
+ "author": "gesslar",
51
+ "license": "Unlicense",
52
+ "contributes": {
53
+ "commands": [
54
+ {
55
+ "command": "vscode-bedoc.generateDocs",
56
+ "title": "BeDoc: Generate Documentation"
57
+ }
58
+ ]
59
+ },
60
+ "extensionKind": [
61
+ "workspace",
62
+ "ui"
63
+ ]
64
+ }
package/src/cli.js ADDED
@@ -0,0 +1,92 @@
1
+ #!/usr/bin/env node
2
+
3
+ import {program} from "commander"
4
+ import console from "node:console"
5
+ import process from "node:process"
6
+
7
+ import BeDoc, {Environment} from "./core/Core.js"
8
+ import {ConfigurationParameters} from "./core/ConfigurationParameters.js"
9
+
10
+ import * as ActionUtil from "./core/util/ActionUtil.js"
11
+ import * as FDUtil from "./core/util/FDUtil.js"
12
+
13
+ const {loadPackageJson} = ActionUtil
14
+ const {resolveDirectory} = FDUtil
15
+
16
+ // Main entry point
17
+ ;(async() => {
18
+ try {
19
+ // Get package info
20
+ const basePath = resolveDirectory(process.cwd())
21
+ const packageJson = loadPackageJson(basePath)
22
+
23
+ // Setup program
24
+ program.name(packageJson.name).description(packageJson.description)
25
+
26
+ // Build CLI
27
+ for(const [name, parameter] of Object.entries(ConfigurationParameters)) {
28
+ let arg = parameter.short
29
+ ? `-${parameter.short}, --${name}`
30
+ : `--${name}`
31
+
32
+ const param = parameter.param ? parameter.param : name
33
+
34
+ if(param)
35
+ arg += parameter.required ? ` <${param}>` : ` [${param}]`
36
+
37
+ const description = `${parameter.description} (${parameter.type})`
38
+ const defaultValue = parameter.default
39
+
40
+ program.option(arg, description, defaultValue)
41
+ }
42
+
43
+ // Add version option last
44
+ program.version(
45
+ packageJson.version,
46
+ "-v, --version",
47
+ "Output the version number",
48
+ )
49
+ program.helpOption("-h, --help", "Output usage information")
50
+ program.parse()
51
+
52
+ // Get options
53
+ const options = program.opts()
54
+
55
+ const sources = program._optionValueSources
56
+ const optionsWithSources = {}
57
+ for(const [key, value] of Object.entries(options)) {
58
+ const element = {
59
+ value,
60
+ source: sources[key],
61
+ }
62
+ optionsWithSources[key] = element
63
+ }
64
+
65
+ // Create core instance with validated config
66
+ BeDoc
67
+ .new({
68
+ options: {
69
+ ...optionsWithSources,
70
+ basePath: {value: basePath, source: "cli"},
71
+ packageJson: {value: packageJson, source: "cli"},
72
+ },
73
+ source: Environment.CLI
74
+ })
75
+ } catch(e) {
76
+ if(e instanceof Error) {
77
+ if(e instanceof AggregateError) {
78
+ for(const error of e.errors) {
79
+ console.error(`Error: ${error.message}`)
80
+ }
81
+ } else if(e.stack) {
82
+ console.error(e.stack)
83
+ } else {
84
+ console.error(`Error: ${e.message}`)
85
+ }
86
+ } else {
87
+ console.error(`Error: ${e}`)
88
+ }
89
+
90
+ process.exit(1)
91
+ }
92
+ })()
@@ -0,0 +1,76 @@
1
+ import {hookPoints} from "./HooksManager.js"
2
+
3
+ export default class ActionManager {
4
+ #action = null
5
+ #meta = {}
6
+ #hooks = null
7
+ #contract
8
+ #module
9
+ #log
10
+ #debug
11
+
12
+ constructor(actionDefinition, logger) {
13
+ this.#log = logger
14
+ this.#debug = this.#log.newDebug()
15
+
16
+ this.#setupAction(actionDefinition)
17
+ }
18
+
19
+ #setupAction(actionDefinition) {
20
+ const debug = this.#debug
21
+
22
+ debug("Setting up action", 2)
23
+
24
+ const {action, contract, module, meta} = actionDefinition
25
+
26
+ if(!action)
27
+ throw new Error("Action is required")
28
+
29
+ if(!contract)
30
+ throw new Error("Contract is required")
31
+
32
+ if(!module)
33
+ throw new Error("Module is required")
34
+
35
+ this.#module = module
36
+ this.#action = action
37
+ this.#contract = contract
38
+ this.#meta = meta
39
+
40
+ debug("Action setup complete", 2)
41
+ }
42
+
43
+ get action() {
44
+ return this.#action
45
+ }
46
+
47
+ get hooks() {
48
+ return this.#hooks
49
+ }
50
+
51
+ set hooks(hookManager) {
52
+ if(this.hooks)
53
+ throw new Error("Hooks already set")
54
+
55
+ this.action.hook = hookManager.on.bind(this.action)
56
+ this.action.HOOKS = hookPoints
57
+ this.action.hooks = hookManager.hooks
58
+ this.#hooks = hookManager
59
+ }
60
+
61
+ get contract() {
62
+ return this.#contract
63
+ }
64
+
65
+ get module() {
66
+ return this.#module
67
+ }
68
+
69
+ get meta() {
70
+ return this.#meta
71
+ }
72
+
73
+ get log() {
74
+ return this.#log
75
+ }
76
+ }