Generate User-Facing Documentation
The "Populate External Docs" command (devdocs.generateExternalDocs
) is a crucial feature of the Dev-Docs VS Code extension that allows you to generate comprehensive documentation for your users. This command analyzes your project's files and generates an external documentation website, which serves as a centralized hub for all your project's documentation.
What Does This VS Code Extension Command Do?
The "Populate External Docs" command performs the following tasks:
- Scans your project's codebase and identifies relevant code elements (classes, functions, methods, etc.) based on the specified filters (
internalTypeFilters
,codeFilters
,nameFilters
). - Optionally includes code snippets from other files or folders specified in the configuration (
importFiles
,importFolders
). - Generates documentation for each identified code element, either by using predefined prompts or employing AI-assisted documentation generation.
- Organizes the generated documentation into a structured format, following the specified mappings (
mappings
) and folder structure (docSubFolder
). - Updates the
dev-docs.json
file with the generated mappings. - Optionally, pushes the updated documentation to a specified Git branch (
branch
).
Why Should I Use This VS Code Extension Command?
Using the "Populate External Docs" command offers several benefits:
- Centralized Documentation Hub: It creates a dedicated website for your project's documentation, making it easily accessible and shareable with team members or external stakeholders.
- Automated Documentation Generation: The command automates the documentation process, saving you time and effort by generating documentation directly from your codebase.
- Consistency and Maintainability: By tying the documentation to your codebase, you ensure that your documentation remains up-to-date as your code evolves.
- Customizable Configuration: The
dev-docs.json
configuration file allows you to tailor the documentation generation process to your project's specific needs, including filtering code elements, specifying import paths, and organizing the documentation structure.
What Are Relevant Configuration Options in the dev-docs.json
?
The following configuration options in the dev-docs.json
file are relevant for the "Populate External Docs" command:
ai.internalTypeFilters
: An array of strings specifying the types of code elements to include in the documentation (e.g.,["class", "method", "function"]
).ai.codeFilters
: An array of strings used to filter code elements based on specific patterns (e.g.,["async function", "export default"]
).ai.nameFilters
: An array of strings used to filter code elements based on their names (e.g.,["handleSubmit", "render"]
).ai.importFiles
: An array of file paths specifying additional files to include in the documentation.ai.importFolders
: An array of folder paths specifying additional folders to include in the documentation.ai.importTypeFilters
: An array of strings specifying the types of code elements to include from the imported files and folders.ai.importCodeFilters
: An array of strings used to filter code elements from the imported files and folders based on specific patterns.ai.importNameFilters
: An array of strings used to filter code elements from the imported files and folders based on their names.ai.branch
: The Git branch to which the updated documentation will be pushed (default:"main"
).ai.mappings
: An array of objects specifying how the generated documentation should be organized and mapped to specific folders or files in the external documentation website.
Example JSON of relevant dev-docs.json
options
Here's an example JSON configuration with the minimum required options to use the "Populate External Docs" command:
{
"ai": {
"internalTypeFilters": ["class", "method", "function"],
"codeFilters": ["async function", "export default"],
"nameFilters": ["handleSubmit", "render"],
"branch": "main",
"mappings": [
{
"files": ["src/main.ts"],
"cloudDir": "Getting Started"
},
{
"folder": ["src/components"],
"cloudDir": "Components"
}
]
}
}
Prerequisites
Before using the "Populate External Docs" command, ensure that you have the following prerequisites in place:
- A
dev-docs.json
configuration file present in your project's root directory, with the necessary configuration options set. - A valid authentication token (
devdocs_id_token
) stored in the VS Code extension's storage, which can be obtained by running thedevdocs.getGitHubUser
command and authenticating with your GitHub account.
How Do I Use This VS Code Extension Command?
To use the "Populate External Docs" command, follow these steps:
- Open your project in VS Code.
- Ensure that the
dev-docs.json
configuration file is properly set up with the relevant options. - Open the Command Palette in VS Code (Ctrl+Shift+P or Cmd+Shift+P).
- Search for the "Populate External Docs" command (
devdocs.generateExternalDocs
) and select it. - The extension will start analyzing your codebase and generating the external documentation based on the configured settings.
- Once the process is complete, you should see a success message in the VS Code output panel, indicating that the external documentation has been generated and updated.