Keyboard Shortcuts N Next post
P Previous post
S Save / unsave
R Read aloud
T Toggle theme
/ Focus search
Esc Close panels
🔥
Ready to read...
Documentation GitHub Copilot IMCSEIAN intermediate Project Static Site Tutorial

Project 10 — Docs-Site Generator from Code Comments

Reviewed & accurate
AI Summary
IMCSEIAN · GitHub Copilot Master Course

Project 10 — Docs-Site Generator from Code Comments

Extract comments, generate markdown, build a static site.

Phase 2 — Intermediate Lesson IN-51 Difficulty: Intermediate 15 min read
Course: GitHub Copilot Phase 2 — Intermediate 15 min read Last verified: 2026-08-30

What You Will Learn

  • Extract code comments.
  • Generate markdown.
  • Build a static site.
  • Automate via CI.
  • Measure onboarding improvement.

Why This Matters

Code docs decay because they're manual. A generator that extracts comments, generates markdown, and builds a site keeps docs fresh with zero manual effort.

Concept Explained

A script that walks src/, extracts docstrings/JSDoc, generates markdown per module, builds a static site (MkDocs, Docusaurus, or similar).

How It Works

Walk src/. For each file, extract docstrings. Generate markdown with function signatures, docstrings, and source links. Build static site. Deploy via CI.

Step-by-Step Tutorial

1. Walk source

For each file in src/.

2. Extract docstrings

Parse JSDoc/Python docstrings.

3. Generate markdown

One .md per module: signature, docstring, examples.

4. Build static site

MkDocs, Docusaurus, or similar.

5. Deploy via CI

GitHub Actions to GitHub Pages or similar.

Real-World Example

A team built a docs-site generator. Every commit regenerated the docs site. New hires could browse API docs, architecture, and examples without reading source. Onboarding time dropped 30%.

Example Prompts / Commands / Code

Generator scriptimcseian
#!/usr/bin/env python3
# generate-docs.py
import ast
import os
from pathlib import Path

SRC_DIR = 'src'
DOCS_DIR = 'docs/api'

for py_file in Path(SRC_DIR).rglob('*.py'):
    module_name = py_file.stem
    docs_file = Path(DOCS_DIR) / f'{module_name}.md'

    with open(py_file) as f:
        tree = ast.parse(f.read())

    content = [f'# {module_name}\n']

    for node in ast.walk(tree):
        if isinstance(node, (ast.FunctionDef, ast.AsyncFunctionDef)):
            docstring = ast.get_docstring(node) or 'No documentation.'
            sig = f'def {node.name}({ast.arguments(args=node.args)})'
            content.append(f'## `{node.name}`\n')
            content.append(f'```python\n{sig}\n```\n')
            content.append(f'{docstring}\n')

    docs_file.parent.mkdir(parents=True, exist_ok=True)
    docs_file.write_text('\n'.join(content))

print('Docs generated. Run: mkdocs build')
CI workflowimcseian
# .github/workflows/docs.yml
name: Build Docs
on:
  push:
    branches: [main]
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: python3 generate-docs.py
      - run: pip install mkdocs && mkdocs build
      - uses: peaceiris/actions-gh-pages@v3
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          publish_dir: ./site

Common Mistakes

  • Generating without filtering — internal/private functions exposed.
  • No CI automation — docs decay.
  • Not linking to source — readers can't verify.
  • Forgetting to deploy — site never updates.

Best Practices

  • Filter: only public functions in docs.
  • Automate via CI on every commit.
  • Link to source (file:line).
  • Deploy automatically (GitHub Pages).
  • Measure onboarding improvement.

Troubleshooting

ProblemHow to Fix
Docstrings are sparseRun /doc on undocumented functions first.
Site is slowLimit to public API. Or split into multiple sites.

Practical Exercise

Your Turn

Build a docs-site generator for a sample project. Generate markdown from code comments. Build a static site. Deploy via CI.

Professional Challenge

Stretch Goal

Add a search feature (MkDocs Material has built-in search). Measure how often new hires use search vs browse.

Key Takeaways

  • Docs generator extracts comments, generates markdown, builds site.
  • Filter to public API.
  • Automate via CI on every commit.
  • Link to source.
  • Deploy automatically.

Frequently Asked Questions

Does this replace hand-written docs?
No — augments. Hand-written for tutorials; generated for API.
Frequency?
Every commit. Docs stay fresh.

Further Reading

Official References

Related lessons: BE-24, BE-47

SEO Metadata

SEO title: Project 10 — Docs-Site Generator from Code Comments

Meta description: Extract comments, generate markdown, build a static site.

Primary keyword: project 10

Secondary keywords: project 10 — docs-site generator from code comments

Search intent: Informational

URL slug: /project-docs-site-generator-code-comments-copilot

Categories: AI Tools, GitHub Copilot

Tags: GitHub Copilot, Intermediate, Project, Documentation, Static Site, IMCSEIAN, Tutorial, IMCSEIAN

Featured image concept: IMCSEIAN lesson card for Project 10 — Docs-Site Generator from Code Comments

Test Your Knowledge
How did you find this?

Comments

Join the discussion! Sign in with your Google or Blogger account, or comment as Anonymous - no account needed. For quick questions, also reach me on Telegram @cytestch.

Comments