webdoc-labs / webdoc

Documentation generator for the web
https://www.webdoclabs.com
Other
79 stars 9 forks source link

Unable to document type statements #78

Open bigtimebuddy opened 3 years ago

bigtimebuddy commented 3 years ago

These error keep popping up for me when I built the docs.

[DocParser]: Failed to parse doc for (@Unnamed){@packages/basis/src/Basis.ts<118, 0>}
[DocParser]: Failed to parse doc for (@Unnamed){@packages/basis/src/Basis.ts<135, 0>}
[DocParser]: Failed to parse doc for (@Unnamed){@packages/basis/src/Basis.ts<145, 0>}
[DocParser]: Failed to parse doc for (@Unnamed){@packages/compressed-textures/src/loaders/CompressedTextureLoader.ts<6, 0>}
[DocParser]: Failed to parse doc for (@Unnamed){@packages/compressed-textures/src/loaders/CompressedTextureLoader.ts<18, 0>}
[DocParser]: Failed to parse doc for (@Unnamed){@packages/compressed-textures/src/resources/CompressedTextureResource.ts<7, 0>}

All these instances are all trying to document type. Here's an example.

/**
 * API provided by basis_universal WebGL library.
 *
 * @ignore
 */
export type BasisBinding = {
    BasisFile: typeof BasisFile,
    initializeBasis(): void
};

Changing this to the following made it go away:

/**
 * API provided by basis_universal WebGL library.
 *
 * @typedef {object} BasisBinding
 * @ignore
 */
export type BasisBinding = {
    BasisFile: typeof BasisFile,
    initializeBasis(): void
};
ShukantPal commented 3 years ago

Ah, yes. webdoc doesn't recognize type definitions from the code. If you don't give it the @typedef tag, it fails to resolve the documentation to any type.

I'll be adding support for this sometime soon. Do you think we should also add type support to pixi-webdoc-template?

ShukantPal commented 3 years ago

Or should type BasisBinding become a typedef by inference?

bigtimebuddy commented 3 years ago

Yeah, I think this should be a typedef by inference. It weird that there's an error though because these statement have @ignore, why is that?

ShukantPal commented 3 years ago

@bigtimebuddy The parser still parses the whole document even if @ignore is specified. @ignore marked documents are pruned after the fact:

https://github.com/webdoc-labs/webdoc/blob/921a6402ff3779c5755d8c48e147650bbbd66dac/packages/webdoc-parser/src/transformer/mod-prune.js#L7

I agree this is a weakness of the architecture.

ShukantPal commented 3 years ago

Inference improvements