code-documentation-skillhub
Installation
Review the source and dependencies with a prompt. A package is available to download.
Install with an AI assistant
Copy the prompt so your assistant can review the pinned revision and dependencies first.
View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "code-documentation-skillhub" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-327be1b07e21af5d30804a8b5e0efb1662aeac095d779a58f5cbcb46ad2f414e. Verify the upstream source and version against https://skillhub.cn/skills/user_3c6cb52e/code-documentation-skillhub before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.
Source and setup
skillhub.cn
Setup guidance pending
See the original source for supported tools, dependencies, and permissions.
Installation test pending
SkillHub skill: a capability label and description for the SkillHub platform.
Introduction source: third_party · user_3c6cb52e · 1.0.0 Reference
SkillPi interpretation
- Tasks
- Translation pending; see source documentation.
- Software, accounts and paid services
- Node.js >= 18 npm or yarn
- Testing
- Not tested
Browse files
Frontmatter
name: 代码文档
slug: "code-documentation"
version: "1.0.0"
displayName: "代码文档"
summary: "自动生成清晰、全面的代码库文档——包括API参考、内联文档字符串、README文件和使用指南。"
description: "自动生成清晰、全面的代码库文档——包括API参考、内联文档字符串、README文件和使用指南。"
license: "MIT"
metadata:
author: "1991513ccie-png"
version: "1.1.0"代码文档
This skill enables an AI agent to analyze source code and produce high-quality documentation in multiple formats. It covers everything from single-function docstrings to full project README files, ensuring that both human developers and downstream tooling (IDEs, doc generators) benefit from consistent, accurate descriptions.
Workflow
-
Inventory the Codebase: Walk the project tree and catalog public modules, classes, functions, constants, and type definitions. Note which symbols already have documentation and which are missing or stale.
-
Determine Documentation Scope: Based on the user's request, decide whether to generate inline docstrings, a standalone API reference, a project-level README, or a combination. Match the output format to the project's existing conventions (JSDoc, Google-style Python docstrings, TypeDoc, RDoc, etc.).
-
Analyze Signatures and Behavior: For each symbol, inspect parameter types, return types, default values, raised exceptions, and side effects. Read surrounding test files when available to understand intended usage and edge cases.
-
Generate Documentation: Write documentation that includes a one-line summary, an extended description when the logic is non-trivial, parameter and return-value documentation with types, exception/error documentation, and at least one usage example for public API surfaces.
-
Insert or Update In-Place: For inline documentation (docstrings, JSDoc comments), insert the generated text directly above or inside the relevant symbol. For standalone files (README, API reference), create or update the Markdown file at the project root or a
docs/directory. -
Validate and Cross-Reference: Verify that documented parameter names match the actual signature, that referenced types exist, and that examples are syntactically valid. Flag any inconsistencies for the user to review.
Supported Formats
- Python: Google-style docstrings, NumPy-style docstrings, Sphinx reStructuredText
- JavaScript / TypeScript: JSDoc (
@param,@returns,@throws), TypeDoc annotations - Java: Javadoc (
@param,@return,@throws) - Go: Godoc comment conventions (comment block immediately above the declaration)
- Rust:
///doc comments with Markdown,#[doc]attributes - Ruby: YARD (
@param,@return,@example) - Markdown: README files, CHANGELOG entries, architecture decision records (ADRs)
Usage
Point the agent at a file, directory, or specific symbol and describe what documentation you need. Examples of valid requests:
- "Add Google-style docstrings to every public function in
src/services/." - "Generate a README for this project based on its structure and package.json."
- "Document this class with JSDoc, including examples for each method."
The agent will respect existing documentation style in the project. If no convention is detected, it will ask which format to use or default to the most common style for the language.
Examples
Example 1 — Documenting a Python Class with Google-Style Docstrings
User Request: "Add docstrings to this class and its methods."
Before:
class TokenBucket:
def __init__(self, capacity, refill_rate):
self.capacity = capacity
self.tokens = capacity
self.refill_rate = refill_rate
self._last_refill = time.monotonic()
def consume(self, tokens=1):
self._refill()
if self.tokens >= tokens:
self.tokens -= tokens
return True
return False
def _refill(self):
now = time.monotonic()
elapsed = now - self._last_refill
self.tokens = min(self.capacity, self.tokens + elapsed * self.refill_rate)
self._last_refill = now
After:
class TokenBucket:
"""A token-bucket rate limiter.
Tokens are added at a constant rate and consumed by callers.
When the bucket is empty, requests are rejected until enough
tokens have accumulated.
Args:
capacity: Maximum number of tokens the bucket can hold.
refill_rate: Tokens added per second.
Example:
>>> bucket = TokenBucket(capacity=10, refill_rate=2)
>>> bucket.consume(3)
True
"""
def __init__(self, capacity: float, refill_rate: float) -> None:
self.capacity = capacity
self.tokens = capacity
self.refill_rate = refill_rate
self._last_refill = time.monotonic()
def consume(self, tokens: int = 1) -> bool:
"""Attempt to consume tokens from the bucket.
Triggers an internal refill based on elapsed time before
checking availability.
Args:
tokens: Number of tokens to consume. Defaults to 1.
Returns:
True if the tokens were available and consumed, False otherwise.
"""
self._refill()
if self.tokens >= tokens:
self.tokens -= tokens
return True
return False
def _refill(self) -> None:
"""Refill the bucket based on time elapsed since the last refill."""
now = time.monotonic()
elapsed = now - self._last_refill
self.tokens = min(self.capacity, self.tokens + elapsed * self.refill_rate)
self._last_refill = now
Example 2 — Generating a Project README from Structure
User Request: "Generate a README for this project."
Given a project with the following layout:
myapi/
├── package.json (name: @acme/myapi, scripts: dev, build, test)
├── src/
│ ├── index.ts (Express app entry point)
│ ├── routes/
│ │ ├── users.ts
│ │ └── orders.ts
│ └── middleware/
│ └── auth.ts
├── tests/
│ └── users.test.ts
└── Dockerfile
Generated README.md:
# @acme/myapi
A RESTful API service built with Express and TypeScript.
## Getting Started
### Prerequisites
- Node.js >= 18
- npm or yarn
### Installation
git clone https://github.com/acme/myapi.git
cd myapi
npm install
### Running Locally
npm run dev # Start the dev server with hot reload
npm run build # Compile TypeScript to dist/
npm test # Run the test suite
### Docker
docker build -t myapi .
docker run -p 3000:3000 myapi
## API Endpoints
| Method | Path | Description |
|--------|----------------|-----------------------|
| GET | /users | List all users |
| POST | /users | Create a new user |
| GET | /orders | List all orders |
| POST | /orders | Create a new order |
## Project Structure
- `src/index.ts` — Application entry point and server bootstrap.
- `src/routes/` — Route handlers grouped by resource.
- `src/middleware/auth.ts` — JWT authentication middleware.
- `tests/` — Jest test files.
## License
MIT
Best Practices
- Match the project's existing style. If the codebase uses NumPy-style docstrings, do not switch to Google-style mid-project. Consistency matters more than personal preference.
- Document the "why," not just the "what." Parameter types are often obvious from signatures; focus on intent, constraints, and non-obvious behavior.
- Include at least one example for every public API symbol. Examples are the most-read part of any documentation and catch subtle misunderstandings.
- Keep README files scannable. Use headings, tables, and code blocks. Developers skim — put the most important information (install, run, deploy) first.
- Do not document private internals unless asked. Over-documenting implementation details creates maintenance burden and can mislead readers into depending on unstable APIs.
- Regenerate docs when the code changes. Stale documentation is worse than no documentation. Prefer tooling that validates docs against signatures at CI time.
Edge Cases
- Dynamically generated APIs: When routes or methods are registered at runtime (e.g., via decorators or plugin systems), static analysis may miss them. Warn the user and suggest runtime introspection or manual annotation.
- Overloaded or generic functions: For TypeScript overloads or Python
@overload, document each signature variant separately with its own parameter descriptions and examples. - Monorepos: When a repository contains multiple packages, generate a root README that links to per-package READMEs rather than one monolithic document.
- Non-English codebases: If variable names and existing comments are in another language, ask the user whether documentation should be in English or the project's primary language.
- Proprietary or sensitive code: Avoid including internal URLs, credentials, or business logic details in generated READMEs that may become public. Redact or generalize where necessary.
Current listing version
1.0.0
Quality assessment
Out of 100 · Assessment report from SkillPi LAB.
Highlights
- 解决开发者高频痛点:自动化生成多语言代码文档,显著降低维护成本
- 覆盖主流编程语言与文档规范,具备广泛适用性
- 提供完整工作流与真实示例,实用性强
Highlights
- 触发词精准完整,涵盖核心功能关键词
- 边界清晰,不易误触或漏触
Highlights
- 结构完整,六步工作流清晰可执行
- 包含高质量端到端示例与最佳实践
- frontmatter 完整,文档长度适中
Highlights
- 工具来源明确,参数处理合理
- 覆盖主要异常与边缘场景,具备强鲁棒性
- 不可逆操作有验证与确认机制
The arithmetic mean of the first four original scores, rounded to a whole number.
Static text checks
100 / 100 · skillpi-20261123-no-r3-v1
No current rules matched the text.
This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.
Permissions and checks before use
Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.
-
Install or fetch external dependencies
Use official sources and pin versions. Check install scripts in an isolated environment. This document check does not cover code downloaded later.
Mentioned in main document · lines 169 -
Accounts, secrets or authorization
Use a dedicated least-privilege account. Keep secrets out of public content and command logs; verify the receiving service and tenant.
Mentioned in main document · lines 218
Domains or addresses referenced in the document
These addresses may be documentation links or examples, not an approved network allowlist. Verify actual destinations and outgoing data before use.
- github.com
Security rating and access scope
safe · Static evidence review; not a runtime safety guarantee.
Node.js >= 18 npm or yarn
Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.
User discussion
No verified reviews yet.