Documentation Requirements for Developers
To ensure high quality and consistency of documentation in the Nrgy.js project, all developers must follow these rules when adding or changing functionality.
General Rules
- Documentation Placement: Source code documentation files should be placed in the same folder as the source file itself.
- Example:
packages/core/src/reactivity.ts->packages/core/src/reactivity.md.
- Localization: Documentation must be translated into English and Russian. AI translation is acceptable.
- The translation should be placed in a separate file with the locale as a suffix.
- Example:
packages/core/src/reactivity.ru.md.
Format: Documentation is written in Markdown format.
No
index.tsFile Articles: Do not create standalone documentation files forindex.tssource files.
- Public package entry points such as
index.tsmust be documented in the package-levelREADME.mdor other package-level documentation instead.
Article Structure for a File (Module)
Each article should contain the following sections:
- Purpose: A brief description of what problem the file/module solves.
- Overview: A more detailed description of the logic and context of use.
- Conceptual Architecture: Description of internal mechanisms and relationships with other parts of the system.
- Public API Description: A list of exported functions, classes, and types with descriptions of parameters and return values.
- Usage Examples: Practical code examples (Code Blocks) demonstrating API usage.
Article Structure for a Package
Each package should have a README.md file in its root (usually next to index.ts or in the root of the package folder) or an index.md file in the general docs folder, containing:
- Package Purpose: Why this package is needed.
- Overview: Main ideas and principles.
- Package Installation: Commands for installation (npm/yarn/pnpm).
- Conceptual Architecture: How the package is organized internally.
- Feature Documentation: Links to key modules or a summary description.
- Usage Examples: Integration examples.
Writing Style
- Use clear and concise technical language.
- Code in examples must be functional and follow project standards.
- Use
inline codeformatting for API function and parameter names. - Keep terminology consistent:
Atom,Effect,Scope,Controller,View Model. - Use level-2 (
##) section headers.
Prompt Template for Documentation Agents
When using an AI agent to generate documentation for a TypeScript source file, apply the following task framing. The agent already has direct file access, so no / placeholders are needed — point it at the file and rely on the rules above.
Task: Analyze the given TypeScript source file and produce documentation for it in Markdown.
Rules:
- Place the new doc next to the source file with the same basename and a
.mdextension. Do not generate a standalone doc forindex.ts; document entry points in the packageREADME.mdinstead.- Produce a Russian translation in a sibling
.ru.mdfile.- Include the five sections listed in Article Structure for a File (Module): Purpose, Overview, Conceptual Architecture, Public API Description, Usage Examples.
- Examples must be valid TypeScript that compiles conceptually against the current public API. Use the consistent terminology listed above.