Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Config option to exclude not explicitly documented symbols #995

Closed
canonic-epicure opened this issue Mar 25, 2019 · 14 comments · Fixed by dbartholomae/redux-dynamic-modules-beacon#25 or gpicron/ssb-subjective-group#1

Comments

@canonic-epicure
Copy link
Contributor

canonic-epicure commented Mar 25, 2019

It seems, currently the approach used by TypeDoc is that all symbols in the source files are included in the resulting documentation. It goes that far, that even symbols that are not exported from the module (and thus not accessible by the users) are also included by default, and one need to use special config to exclude them (excludeNotExported). So users need to explicitly opt-out for specific symbols.

It is probably a reasonable default for the internal documentation, that is supposed to be used by developers, working on the project. However, if the documentation is being written for the end users, the better default would be to opt-in for documentation and hide all symbols that are not explicitly documented.

consider this:

/**
 * This is my cool helper
 */
export function myHelper () : number {
    return helper1() + helper2() + helper3() + ... + helper10()
}

const helper1 = () => 1
const helper2 = () => 2
const helper3 = () => 3

Here the myHelper is a public function and all helperX are private. I'd like to have an option to only include myHelper in the docs, based on the fact, that it is explicitly documented, and, since the helperX helpers have no documentation comments, assume those are private.

@canonic-epicure
Copy link
Contributor Author

PR: #996

@canonic-epicure
Copy link
Contributor Author

Found one problem with the approach I chose - notably the enumeration members are not included, even if the parent enumeration has documentation. I'll peek a bit more

@canonic-epicure
Copy link
Contributor Author

Any suggestion of how to check if a given ts.Node has a generated declaration, that has been included in docs?

@aciccarello
Copy link
Collaborator

Related to #639. What do you think about making this a separate mode instead of a flag? It's something that I suggested in #639 (comment). We probably need to discuss it more because the mode option is not well documented. Is there any reason you'd want to use this with namespaces?

@canonic-epicure
Copy link
Contributor Author

I'm ok with --mode library instead of --exlcludeNotDocumented, as long it will do the same thing.

It seems this feature needs some fine-tuning, for example, it makes little sense to exclude enum members, even if those are not documented. I've tweaked the PR accordingly and currently in the process of writing docs for our project. Will be checking for other possible edge cases.

About namespaces - not sure. Never used them, as its basically a legacy feature of TypeScript if I'm correct. But same point applies to them - if something is not documented explicitly (in the namespace) it is considered private.

@DylanVann
Copy link

This could be taken slightly further, and allow only including members that have a block comment containing @public, this way you could document things internally, and not have them included in documentation for end users.

@aciccarello
Copy link
Collaborator

@DylanVann Currently TypeDoc uses @private and @protected to override the visibility defined by TypeScript so @public might be confusing. There is a plugin which adds a @include tag

There's also @hidden and @ignore which does the opposite and hides symbols.

@DylanVann
Copy link

@aciccarello I have seen those. If it was a new project those might work, but it's a pretty large project where we don't want to expose anything unintentionally (because the API is the contract with users).

I did manage to get it working using @samuraijack's work - DylanVann@0273693#diff-68d2486bc7e7d7e960c74fa3d9466b94R74

@canonic-epicure
Copy link
Contributor Author

@DylanVann yes, make sense, I might adopt your changes as well.

@Gerrit0
Copy link
Collaborator

Gerrit0 commented May 10, 2019

I don't think making this a new mode makes sense, this idea is a different feature request than #639. The proposed --excludeNotDocumented makes sense to me.

I'd like to see a test for undocumented enum members with a documented enum, but otherwise #966 looks good to me.

@aciccarello
Copy link
Collaborator

I would like to support the use case of not-outputting public APIs but wouldn't adding a library mode support this? The only complication would be that types that are referenced by a public api might cause the type to appear in the final output.

Thanks for the PR which helps me understand what you are looking for more clearly. I am concerned that it will be hard to have this flag fit enough people's needs to justify supporting it. What if someone else needs an adjustment to what symbols need to be checked.

I think we would be better off having a clear example of how to create a plugin to modify the reflections that are included.

@canonic-epicure
Copy link
Contributor Author

A plugin idea sounds good for me.

@ELLIOTTCABLE
Copy link

Just 👍 on needing something like this!

Regarding broken links: I think, ideally, "hidden" or "not-included" items should be shipped in the HTML output, but hidden via a CSS property, or JS, or similar; this allows them to be shown on-demand IFF the URL-anchor includes their id. (In other words, "private" stuff doesn't clutter up the documentation; but is still visible if necessary, and links don't break.)

So, ideally,

  1. @include, or another wording, becomes built-in,
  2. the newly-added 'library' mode toggles only those objects which are tagged with neither @hidden nor @include,
  3. and @hidden (or absent-@include) items are rendered into the documentation, and hidden client-side.

Thoughts?

(As a side-note: I'd be wary of stomping, specifically, on the word "include" for the above — as that precludes an intuitive "include external documentation for this item" feature in the future … but I suppose that's a small concern by comparison. ¯\_(ツ)_/¯)

@DylanVann
Copy link

I've migrated to using API Extractor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants