diff --git a/README.md b/README.md index 2dc8000..91d7705 100644 --- a/README.md +++ b/README.md @@ -76,7 +76,7 @@ To generate links to the documented source code, you can also provide the `--rep This library generates Markdown documentation from TypeScript source code for `Functions`, `Constants` and `Classes`. Documentation for `Interfaces` and `Types` is not generated by default. To opt-in for types use the parameter `--types`. -You can also opt-out of generating titles with emojis by using the option `--noemoji`. +You can also opt-out of generating titles with emojis by using the option `--noemoji`. Using above script is of course optional. You can also develop your own JavaScript script and use one of the functions here under. @@ -149,7 +149,7 @@ Parameters: - `params.inputFiles`: The list of files to scan and for which the documentation should be build. - `params.options`: Optional compiler options to generate the docs -[:link: Source](https://github.com/peterpeterparker/tsdoc-markdown/tree/main/src/lib/docs.ts#L398) +[:link: Source](https://github.com/peterpeterparker/tsdoc-markdown/tree/main/src/lib/docs.ts#L402) ### :gear: documentationToMarkdown diff --git a/src/lib/docs.ts b/src/lib/docs.ts index f5dbac9..e5974e0 100644 --- a/src/lib/docs.ts +++ b/src/lib/docs.ts @@ -12,8 +12,7 @@ import type { TypeChecker, Symbol as TypeScriptSymbol, VariableDeclaration, - VariableStatement -} from 'typescript'; + VariableStatement} from 'typescript'; import { ModifierFlags, ModuleKind, @@ -116,6 +115,11 @@ const serializeClass = ({ const isNodeExportedOrPublic = (node: Node): boolean => { const flags = getCombinedModifierFlags(node as Declaration); + // Check for '#' methods or properties + if (isMethodDeclaration(node) && node.name.kind === SyntaxKind.PrivateIdentifier) { + return false; + } + return ( (flags & ModifierFlags.Export) !== 0 || (flags & ModifierFlags.Public) !== 0 || diff --git a/src/test/markdown.spec.ts b/src/test/markdown.spec.ts index 4ecf73c..8ad3c0d 100644 --- a/src/test/markdown.spec.ts +++ b/src/test/markdown.spec.ts @@ -21,7 +21,7 @@ describe('markdown', () => { expect(markdown).toEqual(expectedDoc); }); - it.each([35, 86, 114])('should generate a markdown link to line %s', (line) => { + it.each([35, 101, 129])('should generate a markdown link to line %s', (line) => { const doc = buildDocumentation({ inputFiles: ['./src/test/mock.ts'], options: { diff --git a/src/test/mock.json b/src/test/mock.json index 68dd2c0..d084f2e 100644 --- a/src/test/mock.json +++ b/src/test/mock.json @@ -175,6 +175,13 @@ } ], "doc_type": "function" + }, + { + "name": "shouldBeDocumented", + "documentation": "Public method.", + "type": "() => void", + "jsDocs": [], + "doc_type": "method" } ], "fileName": "src/test/mock.ts" diff --git a/src/test/mock.md b/src/test/mock.md index 3bc2994..c47aa5e 100644 --- a/src/test/mock.md +++ b/src/test/mock.md @@ -86,7 +86,7 @@ function submit() { ``` -[:link: Source](https://github.com/peterpeterparker/tsdoc-markdown/tree/main/src/test/mock.ts#L206) +[:link: Source](https://github.com/peterpeterparker/tsdoc-markdown/tree/main/src/test/mock.ts#L221) ## :wrench: Constants @@ -125,6 +125,7 @@ Parameters: - [create](#gear-create) - [accountBalance](#gear-accountbalance) +- [shouldBeDocumented](#gear-shouldbedocumented) #### :gear: create @@ -146,10 +147,20 @@ Returns the balance of the specified account identifier. [:link: Source](https://github.com/peterpeterparker/tsdoc-markdown/tree/main/src/test/mock.ts#L69) +#### :gear: shouldBeDocumented + +Public method. + +| Method | Type | +| ---------- | ---------- | +| `shouldBeDocumented` | `() => void` | + +[:link: Source](https://github.com/peterpeterparker/tsdoc-markdown/tree/main/src/test/mock.ts#L80) + ## :factory: SnsLedgerCanister -[:link: Source](https://github.com/peterpeterparker/tsdoc-markdown/tree/main/src/test/mock.ts#L86) +[:link: Source](https://github.com/peterpeterparker/tsdoc-markdown/tree/main/src/test/mock.ts#L101) ### Constructors @@ -170,7 +181,7 @@ This create function is public as well. | ---------- | ---------- | | `create` | `(options: { canisterId?: string or undefined; }) => SnsLedgerCanister` | -[:link: Source](https://github.com/peterpeterparker/tsdoc-markdown/tree/main/src/test/mock.ts#L101) +[:link: Source](https://github.com/peterpeterparker/tsdoc-markdown/tree/main/src/test/mock.ts#L116) #### :gear: metadata @@ -180,12 +191,12 @@ The token metadata (name, symbol, etc.). | ---------- | ---------- | | `metadata` | `(params: QueryParams) => Promise` | -[:link: Source](https://github.com/peterpeterparker/tsdoc-markdown/tree/main/src/test/mock.ts#L110) +[:link: Source](https://github.com/peterpeterparker/tsdoc-markdown/tree/main/src/test/mock.ts#L125) ## :factory: default -[:link: Source](https://github.com/peterpeterparker/tsdoc-markdown/tree/main/src/test/mock.ts#L114) +[:link: Source](https://github.com/peterpeterparker/tsdoc-markdown/tree/main/src/test/mock.ts#L129) ### Methods @@ -199,7 +210,7 @@ Description | ---------- | ---------- | | `bar` | `() => void` | -[:link: Source](https://github.com/peterpeterparker/tsdoc-markdown/tree/main/src/test/mock.ts#L118) +[:link: Source](https://github.com/peterpeterparker/tsdoc-markdown/tree/main/src/test/mock.ts#L133) ## :nut_and_bolt: Enum @@ -270,7 +281,7 @@ A type yolo | ---------- | ---------- | | `yolo` | `'string'` | -[:link: Source](https://github.com/peterpeterparker/tsdoc-markdown/tree/main/src/test/mock.ts#L143) +[:link: Source](https://github.com/peterpeterparker/tsdoc-markdown/tree/main/src/test/mock.ts#L158) ### :gear: Abc @@ -280,7 +291,7 @@ A type yolo | ---------- | ---------- | | `Abc` | `Foo and {hello: string}` | -[:link: Source](https://github.com/peterpeterparker/tsdoc-markdown/tree/main/src/test/mock.ts#L148) +[:link: Source](https://github.com/peterpeterparker/tsdoc-markdown/tree/main/src/test/mock.ts#L163) ### :gear: StorageConfigSourceGlob @@ -288,7 +299,7 @@ A type yolo | ---------- | ---------- | | `StorageConfigSourceGlob` | | -[:link: Source](https://github.com/peterpeterparker/tsdoc-markdown/tree/main/src/test/mock.ts#L219) +[:link: Source](https://github.com/peterpeterparker/tsdoc-markdown/tree/main/src/test/mock.ts#L234) ### :gear: SatelliteConfig @@ -296,5 +307,5 @@ A type yolo | ---------- | ---------- | | `SatelliteConfig` | `Either and CliConfig and SatelliteConfigOptions` | -[:link: Source](https://github.com/peterpeterparker/tsdoc-markdown/tree/main/src/test/mock.ts#L245) +[:link: Source](https://github.com/peterpeterparker/tsdoc-markdown/tree/main/src/test/mock.ts#L260) diff --git a/src/test/mock.ts b/src/test/mock.ts index 92a30a4..9c4094e 100644 --- a/src/test/mock.ts +++ b/src/test/mock.ts @@ -74,6 +74,13 @@ export class LedgerCanister { return {icp: 1n}; }; + /** + * Public method. + */ + shouldBeDocumented() { + console.log('hello'); + } + /** * Private method. * @private @@ -81,6 +88,14 @@ export class LedgerCanister { private shouldNoBeDocumented() { console.log('hello'); } + + /** + * Private identifier method. + * @private + */ + #shouldNoBeDocumentedNeither() { + console.log('hello'); + } } export class SnsLedgerCanister extends Canister {