Yes, you can configure TypeDoc to include only files from your “src” directory, even if your tsconfig.json
file has a broader “includes” property. Here are the primary methods to achieve this:
1. Using the --exclude
option:
-
When running TypeDoc from the command line, pass the
--exclude
option multiple times to specify the directories you want to exclude:Bashtypedoc --exclude "**/node_modules/**" --exclude "**/tests/**" --out docs src
- This command will generate documentation from files in the “src” directory, while excluding files in “node_modules” and “tests” directories.
2. Using a configuration file:
-
Create a TypeDoc configuration file (e.g.,
typedoc.json
ortypedoc.js
) with the following options:JSON{ "exclude": [ "**/node_modules/**", "**/tests/**" ], "entryPoints": ["./src"] }
-
Then, run TypeDoc without explicitly specifying input files:
Bashtypedoc --out docs
3. Contextualizing with tsconfigReferences
(for complex projects):
-
If your project involves multiple
tsconfig.json
files, set thetsconfigReferences
option in your TypeDoc configuration file to ensure correct context for file inclusion:JSON{ "exclude": [ "**/node_modules/**", "**/tests/**" ], "entryPoints": ["./src"], "tsconfig": ["./tsconfig.json"], "tsconfigReferences": true }
Remember:
- Place the configuration file in the root of your project or a directory named
.config
. - Adjust exclude patterns and entry points based on your specific project structure.
By following these methods, you can effectively control which files are included in your TypeDoc-generated documentation, ensuring it focuses solely on your desired source code.