microsoft / tsdoc

A doc comment standard for TypeScript
https://tsdoc.org/
MIT License
4.71k stars 131 forks source link

Add a new tsdoc.json setting "noStandardTags" #279

Closed octogonz closed 3 years ago

octogonz commented 3 years ago

TSDocConfigFile.loadFromParser() generates a tsdoc.json file from the API object, which can be used to produce a single file that rolls up another tsdoc.json file, plus its "extends" references, plus the predefined standard tags for the current TSDoc version. This is useful for serializing the exact TSDoc configuration for later usage.

However, normally tsdoc.json files are loaded with a set of predefined standard tags, which would conflict with the serialized copy of those definitions. This PR solves that problem by adding a "noStandardTags" that instructs the loader not to predefine any tags.

It might also be useful for a custom tsdoc.json configuration that wants to be substantially different from the standard tags. Or for example, if we wanted to publish tsdoc.json config files that represent previous versions of the TSDoc standard. So this feature can be generally useful.

Design note

I initially approached this by moving the standard definitions into a standard-tsdoc.json file (rather than having them declared in code). The idea was that a custom tsdoc.json file would always have a line like this:

  "extends": ["@microsoft/tsdoc/includes/standard-tsdoc.json"],

This seemed elegant, because the predefined values are now in a nice JSON file, and their existence is explicitly specified using the familiar "extends" mechanism. But I realized that it would be clunky in practice: