|
| 1 | +# Advanced configuring dev-docs.json for Generating Documentation |
| 2 | + |
| 3 | +The `dev-docs.json` file offers various configuration options to customize how Dev-Docs generates documentation for your code files. This guide focuses on the "ai" section of the configuration, which provides powerful features for tailoring the documentation process. |
| 4 | + |
| 5 | +## AI Section Configuration |
| 6 | + |
| 7 | +The "ai" section in `dev-docs.json` allows you to set up specific prompts and filters for different files or directories in your project. Here's an overview of the key configuration options: |
| 8 | + |
| 9 | +### 1. File-Specific Prompts |
| 10 | + |
| 11 | +You can define custom prompts for individual files using the following structure: |
| 12 | + |
| 13 | +```json |
| 14 | +"ai": { |
| 15 | + "variablesAndFunctions": { |
| 16 | + "path/to/your/file.js": { |
| 17 | + "prompts": [ |
| 18 | + { |
| 19 | + "title": "Function Purpose", |
| 20 | + "question": "What is the main purpose of this function?", |
| 21 | + "documentation": "Explain the function's primary role in the codebase." |
| 22 | + }, |
| 23 | + { |
| 24 | + "title": "Input Parameters", |
| 25 | + "question": "What are the input parameters for this function?", |
| 26 | + "documentation": "" |
| 27 | + } |
| 28 | + ] |
| 29 | + } |
| 30 | + } |
| 31 | +} |
| 32 | +``` |
| 33 | + |
| 34 | +### 2. Directory-Specific Prompts |
| 35 | + |
| 36 | +To apply prompts to all files within a specific directory: |
| 37 | + |
| 38 | +```json |
| 39 | +"ai": { |
| 40 | + "variablesAndFunctions": { |
| 41 | + "src/components": { |
| 42 | + "prompts": [ |
| 43 | + { |
| 44 | + "title": "Component Overview", |
| 45 | + "question": "Provide a brief overview of this component.", |
| 46 | + "documentation": "" |
| 47 | + } |
| 48 | + ] |
| 49 | + } |
| 50 | + } |
| 51 | +} |
| 52 | +``` |
| 53 | + |
| 54 | +### 3. Global Filters |
| 55 | + |
| 56 | +You can set global filters to control which symbols are documented: |
| 57 | + |
| 58 | +```json |
| 59 | +"ai": { |
| 60 | + "internalTypeFilters": ["class", "method", "function"], |
| 61 | + "codeFilters": ["async function", "export default"], |
| 62 | + "nameFilters": ["handleSubmit", "render"] |
| 63 | +} |
| 64 | +``` |
| 65 | + |
| 66 | +### 4. Import Handling |
| 67 | + |
| 68 | +Configure how imports are handled in documentation: |
| 69 | + |
| 70 | +```json |
| 71 | +"ai": { |
| 72 | + "importFolders": ["src/utils", "src/helpers"], |
| 73 | + "importFiles": ["src/constants.js", "src/types.ts"], |
| 74 | + "importTypeFilters": ["class", "function"], |
| 75 | + "importCodeFilters": ["export const"], |
| 76 | + "importNameFilters": ["util", "helper"] |
| 77 | +} |
| 78 | +``` |
| 79 | + |
| 80 | +### 5. Documentation Output |
| 81 | + |
| 82 | +Customize the output of generated documentation: |
| 83 | + |
| 84 | +```json |
| 85 | +"ai": { |
| 86 | + "docPath": "docs/api-reference", |
| 87 | + "docSubFolder": "components", |
| 88 | + "populateDoc": "docs/template.md", |
| 89 | + "branch": "documentation-updates" |
| 90 | +} |
| 91 | +``` |
| 92 | + |
| 93 | +### 6. Context Prompts |
| 94 | + |
| 95 | +Add custom context prompts for more detailed documentation: |
| 96 | + |
| 97 | +```json |
| 98 | +"ai": { |
| 99 | + "contextPrompt": "dev-docs/context-prompt-template.md", |
| 100 | + "folderContextPrompt": "dev-docs/folder-context-template.md" |
| 101 | +} |
| 102 | +``` |
| 103 | + |
| 104 | +### 7. Code Summary |
| 105 | + |
| 106 | +Customize the code summary generation: |
| 107 | + |
| 108 | +```json |
| 109 | +"ai": { |
| 110 | + "codeSummaryPrompt": "Provide 3 bullet points summarizing the code's functionality", |
| 111 | + "defaultLength": "3-5 Sentences" |
| 112 | +} |
| 113 | +``` |
| 114 | + |
| 115 | +### 8. File Mappings |
| 116 | + |
| 117 | +Define custom mappings for documentation organization: |
| 118 | + |
| 119 | +```json |
| 120 | +"ai": { |
| 121 | + "mappings": [ |
| 122 | + { |
| 123 | + "files": ["src/main.ts"], |
| 124 | + "cloudDir": "Getting Started" |
| 125 | + }, |
| 126 | + { |
| 127 | + "folder": ["src/components"], |
| 128 | + "cloudDir": "Components" |
| 129 | + } |
| 130 | + ] |
| 131 | +} |
| 132 | +``` |
| 133 | + |
| 134 | +## Best Practices |
| 135 | + |
| 136 | +1. Start with global filters and gradually add file-specific or directory-specific prompts as needed. |
| 137 | + |
| 138 | +2. Use context prompts to provide additional information about your project's structure or conventions. |
| 139 | + |
| 140 | +3. Regularly review and update your `dev-docs.json` configuration as your project evolves. |
| 141 | + |
| 142 | +4. Utilize the `mappings` feature to organize your documentation in a logical structure. |
| 143 | + |
| 144 | +5. Leverage import handling to ensure comprehensive documentation of dependencies and utilities. |
| 145 | + |
| 146 | +By carefully configuring these options in your `dev-docs.json` file, you can create highly tailored and comprehensive documentation for your codebase, enhancing its maintainability and accessibility for developers. |
0 commit comments