@satisfactory-dev/docdown 0.1.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.
package/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright 2011-2016 John-David Dalton
4
+ Copyright 2026 SignpostMarv
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,33 @@
1
+ # Satisfactory.dev docdown Fork
2
+
3
+ [![Coverage Status](https://coveralls.io/repos/github/satisfactory-dev/docdown/badge.svg?branch=main)](https://coveralls.io/github/satisfactory-dev/docdown?branch=main)
4
+ [![Workflow Status](https://github.com/satisfactory-dev/docdown/actions/workflows/nodejs.yml/badge.svg?branch=main)](https://github.com/satisfactory-dev/docdown/actions/workflows/nodejs.yml?query=branch%3Amain)
5
+
6
+ A simple JSDoc to Markdown documentation generator.
7
+
8
+ Forked from [docdown](https://github.com/jdalton/docdown)
9
+
10
+ ## Docs
11
+
12
+ * [index.js](doc/index.md)
13
+ * lib
14
+ - [alias.js](doc/lib/alias.md)
15
+ - [entry.js](doc/lib/entry.md)
16
+ - [generator.js](doc/lib/generator.md)
17
+ - [util.js](doc/lib/util.md)
18
+
19
+ ## Usage
20
+
21
+ ```js
22
+ var docdown = require('@satisfactory-dev/docdown');
23
+
24
+ var markdown = docdown({
25
+ 'path': filepath,
26
+ 'url': 'https://github.com/username/project/blob/master/my.js'
27
+ });
28
+ ```
29
+
30
+ ```Makefile
31
+ docs:
32
+ node bin/docdown index.js doc/README.md style=github title="docdown <sup>$(shell git rev-parse HEAD)$</sup>" url=https://github.com/username/project/blob/$(shell git rev-parse HEAD)$/my.js
33
+ ```
package/bin/docdown.js ADDED
@@ -0,0 +1,86 @@
1
+ #!/usr/bin/env node
2
+ /*!
3
+ * docdown
4
+ * Copyright 2011-2016 John-David Dalton
5
+ * Copyright 2026 SignpostMarv
6
+ * Available under MIT license
7
+ */
8
+
9
+ /** Load Node.js modules */
10
+ import {
11
+ existsSync,
12
+ readFileSync,
13
+ writeFileSync,
14
+ } from 'node:fs';
15
+ import {
16
+ join,
17
+ } from 'node:path';
18
+
19
+ /** Load other modules */
20
+ import fromContext from '../bin-lib/options.js';
21
+ import help from '../bin-lib/help.js';
22
+ import docdown from '../index.js';
23
+
24
+ const getOption = fromContext(process.argv);
25
+
26
+ /** The list of arguments provided */
27
+ var argv = process.argv;
28
+
29
+ /*----------------------------------------------------------------------------*/
30
+
31
+ var cwd = process.cwd(),
32
+ fileName = argv[2],
33
+ outputFile = argv[3];
34
+
35
+ if (
36
+ !fileName ||
37
+ !outputFile ||
38
+ argv.includes('-h') ||
39
+ argv.includes('--help')
40
+ ) {
41
+ console.log(help());
42
+ process.exit(1);
43
+ }
44
+
45
+ fileName = join(cwd, fileName);
46
+ outputFile = join(cwd, outputFile);
47
+
48
+ var options = {
49
+ 'lang': getOption('lang'),
50
+ 'path': fileName,
51
+ 'sort': getOption('sort'),
52
+ 'style': getOption('style'),
53
+ 'title': getOption('title'),
54
+ 'toc': getOption('toc'),
55
+ 'url': getOption('url'),
56
+ tocLink: getOption('tocLink'),
57
+ };
58
+
59
+ var output = docdown(options);
60
+
61
+ const previous = existsSync(outputFile) ? readFileSync(outputFile).toString() : '';
62
+
63
+ if (
64
+ !getOption('--force', false) &&
65
+ options.style == 'github' &&
66
+ 'string' === typeof options.url &&
67
+ previous != '' &&
68
+ /\/blob\/[0-9a-f]{40}\//.test(options.url)
69
+ ) {
70
+ const previousWithoutGitCommitHash = previous.replace(/\b[0-9a-f]{40}\b/g, '');
71
+ const currentWithoutGitCommitHash = output.replace(/\b[0-9a-f]{40}\b/g, '');
72
+
73
+ if (previousWithoutGitCommitHash == currentWithoutGitCommitHash) {
74
+ console.log(
75
+ `skipping write to ${
76
+ fileName
77
+ }, as contents have not changed. pass force argument to force update.`
78
+ );
79
+
80
+ process.exit(0)
81
+ }
82
+ }
83
+
84
+ writeFileSync(outputFile, output, 'utf8');
85
+
86
+ process.exit(0);
package/index.js ADDED
@@ -0,0 +1,53 @@
1
+ /*!
2
+ * docdown
3
+ * Copyright 2011-2016 John-David Dalton
4
+ * Copyright 2026 SignpostMarv
5
+ * Available under MIT license
6
+ */
7
+
8
+ import {
9
+ readFileSync,
10
+ } from 'node:fs';
11
+
12
+ import {
13
+ basename,
14
+ } from 'node:path';
15
+
16
+ import generator from './lib/generator.js';
17
+
18
+ /**
19
+ * Generates Markdown documentation based on JSDoc comments.
20
+ *
21
+ * @param {Object} options The options object.
22
+ * @param {string} options.path The input file path.
23
+ * @param {string} options.url The source URL.
24
+ * @param {string} [options.lang='js'] The language indicator for code blocks.
25
+ * @param {boolean} [options.sort=true] Specify whether entries are sorted.
26
+ * @param {string} [options.style='default'] The hash style for links ('default' or 'github').
27
+ * @param {string} [options.title='<%= basename(options.path) %> API documentation'] The documentation title.
28
+ * @param {string} [options.toc='properties'] The table of contents organization style ('categories' or 'properties').
29
+ * @returns {string} The generated Markdown code.
30
+ */
31
+ function docdown({
32
+ lang = 'js',
33
+ sort = true,
34
+ style = 'default',
35
+ title,
36
+ toc = 'properties',
37
+ ...options
38
+ } = {}) {
39
+ if (!options.path || !options.url) {
40
+ throw new Error('Path and URL must be specified');
41
+ }
42
+
43
+ return generator(readFileSync(options.path, 'utf8'), {
44
+ ...options,
45
+ lang,
46
+ sort,
47
+ style,
48
+ title: title == undefined ? basename(options.path) + ' API documentation' : title,
49
+ toc,
50
+ });
51
+ }
52
+
53
+ export default docdown;
package/lib/alias.js ADDED
@@ -0,0 +1,220 @@
1
+ /*!
2
+ * docdown
3
+ * Copyright 2011-2016 John-David Dalton
4
+ * Copyright 2026 SignpostMarv
5
+ * Available under MIT license
6
+ */
7
+
8
+ class Alias {
9
+ /** @type {Object} */
10
+ #owner;
11
+
12
+ /** @type {string} */
13
+ #name;
14
+
15
+ /**
16
+ * The Alias constructor.
17
+ *
18
+ * @param {string} name The alias name.
19
+ * @param {Object} owner The alias owner.
20
+ */
21
+ constructor(name, owner) {
22
+ this.#owner = owner;
23
+ this.#name = name;
24
+ }
25
+
26
+ /**
27
+ * Extracts the entry's `alias` objects.
28
+ *
29
+ * @param {number} [index] The index of the array value to return.
30
+ * @returns {Array|string} Returns the entry's `alias` objects.
31
+ */
32
+ getAliases(index) {
33
+ return index == null ? [] : undefined;
34
+ }
35
+
36
+ /**
37
+ * Extracts the function call from the owner entry.
38
+ *
39
+ * @returns {string} Returns the function call.
40
+ */
41
+ getCall() {
42
+ return this.#owner.getCall();
43
+ }
44
+
45
+ /**
46
+ * Extracts the owner entry's `category` data.
47
+ *
48
+ * @returns {string} Returns the owner entry's `category` data.
49
+ */
50
+ getCategory() {
51
+ return this.#owner.getCategory();
52
+ }
53
+
54
+ /**
55
+ * Extracts the owner entry's description.
56
+ *
57
+ * @returns {string} Returns the owner entry's description.
58
+ */
59
+ getDesc() {
60
+ return this.#owner.getDesc();
61
+ }
62
+
63
+ /**
64
+ * Extracts the owner entry's `example` data.
65
+ *
66
+ * @returns {string} Returns the owner entry's `example` data.
67
+ */
68
+ getExample() {
69
+ return this.#owner.getExample();
70
+ }
71
+
72
+ /**
73
+ * Extracts the entry's hash value for permalinking.
74
+ *
75
+ * @param {string} [style] The hash style.
76
+ * @returns {string} Returns the entry's hash value (without a hash itself).
77
+ */
78
+ getHash(style) {
79
+ return this.#owner.getHash(style);
80
+ }
81
+
82
+ /**
83
+ * Resolves the owner entry's line number.
84
+ *
85
+ * @returns {number} Returns the owner entry's line number.
86
+ */
87
+ getLineNumber() {
88
+ return this.#owner.getLineNumber();
89
+ }
90
+
91
+ /**
92
+ * Extracts the owner entry's `member` data.
93
+ *
94
+ * @param {number} [index] The index of the array value to return.
95
+ * @returns {Array|string} Returns the owner entry's `member` data.
96
+ */
97
+ getMembers(index) {
98
+ return this.#owner.getMembers(index);
99
+ }
100
+
101
+ /**
102
+ * Extracts the owner entry's `name` data.
103
+ *
104
+ * @returns {string} Returns the owner entry's `name` data.
105
+ */
106
+ getName() {
107
+ return this.#name;
108
+ }
109
+
110
+ /**
111
+ * Gets the owner entry object.
112
+ *
113
+ * @returns {Object} Returns the owner entry.
114
+ */
115
+ getOwner() {
116
+ return this.#owner;
117
+ }
118
+
119
+ /**
120
+ * Extracts the owner entry's `param` data.
121
+ *
122
+ * @param {number} [index] The index of the array value to return.
123
+ * @returns {Array} Returns the owner entry's `param` data.
124
+ */
125
+ getParams(index) {
126
+ return this.#owner.getParams(index);
127
+ }
128
+
129
+ /**
130
+ * Extracts the owner entry's `returns` data.
131
+ *
132
+ * @returns {string} Returns the owner entry's `returns` data.
133
+ */
134
+ getReturns() {
135
+ return this.#owner.getReturns();
136
+ }
137
+
138
+ /**
139
+ * Extracts the owner entry's `since` data.
140
+ *
141
+ * @returns {string} Returns the owner entry's `since` data.
142
+ */
143
+ getSince() {
144
+ return this.#owner.getSince();
145
+ }
146
+
147
+ /**
148
+ * Extracts the owner entry's `type` data.
149
+ *
150
+ * @returns {string} Returns the owner entry's `type` data.
151
+ */
152
+ getType() {
153
+ return this.#owner.getType();
154
+ }
155
+
156
+ /**
157
+ * Checks if the entry is an alias.
158
+ *
159
+ * @returns {boolean} Returns `true`.
160
+ */
161
+ isAlias() {
162
+ return true;
163
+ }
164
+
165
+ /**
166
+ * Checks if the owner entry is a constructor.
167
+ *
168
+ * @returns {boolean} Returns `true` if a constructor, else `false`.
169
+ */
170
+ isCtor() {
171
+ return this.#owner.isCtor();
172
+ }
173
+
174
+ /**
175
+ * Checks if the entry is a function reference.
176
+ *
177
+ * @returns {boolean} Returns `true` if the entry is a function reference, else `false`.
178
+ */
179
+ isFunction() {
180
+ return this.#owner.isFunction();
181
+ }
182
+
183
+ /**
184
+ * Checks if the owner entry is a license.
185
+ *
186
+ * @returns {boolean} Returns `true` if a license, else `false`.
187
+ */
188
+ isLicense() {
189
+ return this.#owner.isLicense();
190
+ }
191
+
192
+ /**
193
+ * Checks if the owner entry *is* assigned to a prototype.
194
+ *
195
+ * @returns {boolean} Returns `true` if assigned to a prototype, else `false`.
196
+ */
197
+ isPlugin() {
198
+ return this.#owner.isPlugin();
199
+ }
200
+
201
+ /**
202
+ * Checks if the owner entry is private.
203
+ *
204
+ * @returns {boolean} Returns `true` if private, else `false`.
205
+ */
206
+ isPrivate() {
207
+ return this.#owner.isPrivate();
208
+ }
209
+
210
+ /**
211
+ * Checks if the owner entry is *not* assigned to a prototype.
212
+ *
213
+ * @returns {boolean} Returns `true` if not assigned to a prototype, else `false`.
214
+ */
215
+ isStatic() {
216
+ return this.#owner.isStatic();
217
+ }
218
+ }
219
+
220
+ export default Alias;