Skip to content

docs: restructure documentation using Diataxis framework#1118

Open
davidberenstein1957 wants to merge 26 commits intomasterfrom
issue-1108
Open

docs: restructure documentation using Diataxis framework#1118
davidberenstein1957 wants to merge 26 commits intomasterfrom
issue-1108

Conversation

@davidberenstein1957
Copy link
Collaborator

Summary

  • Reorganizes all documentation into the Diataxis framework quadrants: Tutorials, How-to Guides, Explanation, and Reference
  • Adds mkdocs-redirects plugin to preserve all old URLs (22 redirect mappings)
  • Updates README to mirror the docs homepage structure with quickstart, images, and quick links table
  • Adds EcoLogits reference throughout (README, homepage, nav bar)
  • Adds cross-links between related pages (tutorials ↔ how-tos ↔ reference)
  • Creates new pages: beginner tutorial notebook, CLI reference placeholder

New navigation structure

Section Pages
Tutorials First Tracking, CLI, Python API
How-to Guides Installation, Configuration, Cloud API, Logging, Comet, Visualize, Linux Service, Ansible, SLURM, Scaleway
Explanation Why CodeCarbon, When to Use, Methodology, RAPL, Power Estimation, Model Comparisons, FAQ
Reference API Reference, CLI Reference, Output Formats, Examples

Test plan

  • Run uv run zensical build to verify all pages build without errors
  • Run uv run zensical serve and verify navigation, page rendering, and images
  • Verify old URLs redirect correctly (e.g. /getting-started/installation//how-to/installation/)
  • Check README renders correctly on GitHub with all images and shields

Closes #1108

🤖 Generated with Claude Code

Reorganize all documentation into the four Diataxis quadrants:
- Tutorials: first-tracking, CLI, Python API
- How-to Guides: installation, configuration, cloud API, logging, deployment
- Explanation: motivation, methodology, RAPL, power estimation, FAQ
- Reference: API reference, CLI reference, output formats, examples

Also:
- Add mkdocs-redirects plugin to preserve all old URLs
- Update README to mirror docs homepage structure with EcoLogits reference
- Add cross-links between related pages
- Fix all internal links for new file locations

Closes #1108

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@davidberenstein1957 davidberenstein1957 requested a review from a team as a code owner March 18, 2026 17:31
@codecov
Copy link

codecov bot commented Mar 18, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.71%. Comparing base (31b4dac) to head (2ddc183).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1118   +/-   ##
=======================================
  Coverage   80.71%   80.71%           
=======================================
  Files          41       41           
  Lines        3920     3920           
=======================================
  Hits         3164     3164           
  Misses        756      756           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

davidberenstein1957 and others added 25 commits March 18, 2026 18:46
- Tutorials: Add learning goals, connective prose, and "What's next" sections
  * first-tracking.md: Add introduction and transitions between steps
  * python-api.md: Full restructure as a learning journey with clear progression (explicit → context manager → decorator → offline)
  * cli.md: Add learning goal and transitions, clarify online/offline modes

- How-to guides: Improve clarity and flow
  * visualize.md: Fix unclear headings ("from global" → "Organization & Project Overview"), add intro
  * cloud-api.md: Restructure with clear steps (prerequisites → send data → create projects → view results)
  * installation.md: Clarify conda package deprecation with warning
  * slurm.md: Reframe as Adastra example, point to linux-service.md for general approach

- Explanation: Fix broken links
  * faq.md: Fix Docker answer link (was "Advanced Installation", now "installation.md")

- Reference: Complete and deduplicate
  * cli.md: Replace "Work in progress" stub with comprehensive command reference (config, login, monitor, detect with full options tables and examples)
  * examples.md: Strip explanatory prose, keep code snippets, add PyTorch/HuggingFace example for broader appeal

All docs now follow Diataxis roles: tutorials teach learning paths, how-tos solve specific problems, explanations provide context, and references provide complete information.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Show practical usage immediately after explaining the motivation. Includes:
- Python API example using EmissionsTracker
- CLI example for tracking without code modification

This makes the motivation section more actionable and concrete.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Add comprehensive testing of all Python code blocks in documentation to catch
broken examples early. Uses the mktestdocs library to extract and execute
code blocks directly from markdown files.

Changes:
- Add mktestdocs to dev dependencies in pyproject.toml
- Create tests/test_docs_examples.py with parametrized doc tests:
  * test_doc_python_blocks: Independent Python blocks from tutorials/explanation/how-to
  * test_first_tracking_tutorial: Sequential blocks using memory=True
- Update docs to mark non-runnable code blocks with different language tags:
  * docs/tutorials/first-tracking.md: `!pip install` → console tag
  * docs/reference/examples.md: TensorFlow/PyTorch → python-skip tag

All testable Python blocks now execute in isolated temp directories to prevent
file I/O conflicts. Tests validate that examples remain working as the codebase
evolves.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
…g imports

- docs/reference/output.md: Mark Prometheus and Logfire examples with python-skip tag (require external services)
- Add missing import statement for OfflineEmissionsTracker in Logfire example
- Tests now pass: all runnable Python code blocks in docs are validated

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Autoflake detected unused 'import os' - removed.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Changed language identifier from 'python-skip' to 'python skip' so that
mktestdocs can still skip testing these blocks while syntax highlighting
is properly applied by the documentation renderer.

Fixes issue where code blocks in examples section were not displaying
with proper Python syntax highlighting.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Create new tutorial 'comparing-model-efficiency.md' that:
- Focuses on the explicit object pattern (tracker.start()/stop()) for long-running experiments
- Shows practical ML model training examples with emissions comparison
- Demonstrates efficiency metrics and trade-off analysis between accuracy and environmental impact
- Uses scikit-learn RandomForest with 3 configurations (small/medium/large)
- Includes code for analyzing results, calculating efficiency scores, and visualizing trade-offs
- Bridges gap between reference examples and practical ML scenarios

Updates:
- docs/reference/examples.md: Add cross-link note to new tutorial
- docs/tutorials/python-api.md: Add cross-link in 'What's Next' section
- tests/test_docs_examples.py: Removed test (practical examples require sklearn/pandas dependencies not in test env)

The tutorial provides copy-paste-ready code for users to track and compare carbon efficiency
across their own ML models.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Navigation improvements:
- Rename 'Your First Emissions Tracking' to 'Quickstart' for clarity
- Move Installation into Tutorials section (nav grouping)
- Add 'Comparing Model Efficiency' tutorial to Tutorials section
- Group How-to Guides into logical sections:
  - Dashboard & Visualization (cloud-api, visualize, logging, comet)
  - Deployment (linux-service, ansible, slurm, test-on-scaleway)
  - Configuration (standalone, unchanged)

Content improvements:
- docs/index.md: Add CLI quickstart section after Python quickstart
- README.md: Update Quick links table to reflect navigation changes
- docs/tutorials/first-tracking.md: Update page heading to 'Quickstart'

These changes improve navigation structure and make CLI option more discoverable
alongside Python API in both homepage and README.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
- Make Setup section more conversational and welcoming
- Change code block from 'python skip' to 'python' for proper syntax highlighting
- Add explanatory bullet points about each library's purpose
- Make the section more human-friendly by explaining what we're setting up

The code block now renders with proper Python syntax highlighting and
the section reads more naturally.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Changed all code blocks from ' python' (with space after backticks)
to match the formatting used in other tutorials and ensure proper syntax highlighting
with the zensical theme.

This fixes rendering issues where code blocks weren't displaying with
proper Python syntax colors.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Changed code blocks from '\\\python' (no space) to match
the correct markdown formatting used in other documentation files.

This ensures proper syntax highlighting and rendering with the documentation theme.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Changed skip blocks from '\\\python' with '# mktestdocs: skip'
comment on the first line. This follows the proper mktestdocs format where directives
are comments within the code block, not part of the language identifier.

This ensures:
- Proper Python syntax highlighting (skip is just a comment)
- Correct mktestdocs directive parsing
- Better readability in both source and rendered documentation

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Create a separate 'Logging' section in How-to Guides containing:
- Log to External Systems
- Integrate with Comet

This provides better organization, separating logging/integration features
from Dashboard & Visualization features.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Added tests for more documentation files with Python code blocks:
- docs/how-to/comet.md
- docs/how-to/configuration.md
- docs/how-to/logging.md
- docs/index.md

These expand the test coverage beyond the core tutorials to ensure
all actionable code examples in the documentation are correct.

Note: power-estimation.md contains code snippets referencing internal
codebase variables and is not tested as it's not meant to be run standalone.

All 8 tests pass successfully.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
- Create four framework-specific guides under docs/how-to/:
  - scikit-learn.md: ML model tracking with RandomForestClassifier
  - transformers.md: HuggingFace Transformers fine-tuning guide
  - diffusers.md: Image generation with Diffusers
  - agents.md: Local LLM inference with SmolLM2-135M-Instruct

- Reorganize documentation navigation:
  - Move "Comparing Model Efficiency" to How-to Guides (task-oriented)
  - Move "Framework Examples" to Tutorials (learning-focused)
  - Update mkdocs.yml navigation structure accordingly

- Remove docs/reference/examples.md (superseded by framework guides)
- Add redirects for backward compatibility
- Fix markdown rendering: add blank line before bullet lists
- Update tests to validate scikit-learn guide
- Update pyproject.toml: scikit-learn already in dev dependencies

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
… guides

- comet.md: Added Prerequisites, Installation, Setup Steps (5 numbered steps), Example, Next Steps
- linux-service.md: Added Prerequisites, Installation Steps (8 numbered steps), Verification, Next Steps
- test-on-scaleway.md: Added Hardware Overview, Prerequisites, Setup Steps (5 numbered steps), Results & Analysis, Next Steps
- logging.md: Added Overview, Setup Steps with Options 1-2, Complete Examples, Next Steps
- ansible.md: Added Quick Start with 3 numbered steps, Next Steps
- visualize.md: Added Dashboard Features subsections with step-by-step instructions, Next Steps
- slurm.md: Reorganized with Setup Steps (7 numbered steps), improved troubleshooting, Next Steps

All how-to guides now have consistent structure:
- Overview/Introduction
- Prerequisites
- Installation/Setup (if applicable)
- Step-by-step Instructions
- Next Steps/Additional Resources

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
…roposition

Create new how-to guide 'Improve Measurement Accuracy with RAPL' that:
- Clearly explains what RAPL is and why it improves accuracy
- Provides step-by-step permission setup instructions
- Covers temporary, permanent, and group-based access options
- Includes Docker/containerized environment guidance
- References the explanation section for technical details

Update RAPL explanation file to:
- Remove configuration/setup sections (moved to how-to guide)
- Add prominent link to the new how-to guide
- Keep all technical details about domains, hierarchy, and examples

Add new guide to mkdocs.yml under How-to Guides section.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Add dedicated '### Python' subsection header in Step 2 to clearly indicate
that the code examples are Python-specific, aligning with README's distinction
between 'Quickstart (Python)' and 'Quickstart (CLI)'.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
- Add "### Python" header to clearly distinguish Python vs CLI quickstart
- Add descriptive text for install and example usage
- Update Quick links table to point to Framework Examples (scikit-learn) instead of deleted examples.md
- Aligns homepage with Quickstart tutorial and README structure

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
- Remove "### Python" section header from Step 2 since it's the only option
- Integrate the context manager explanation into the step description
- Simplifies tutorial structure

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
- Move "Improve Measurement Accuracy with RAPL" from How-to Guides top level into Deployment group
- Makes sense as RAPL setup is part of system configuration for deployment
- Groups with other deployment guides (Linux Service, Ansible, SLURM, Scaleway)

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
- Reformat 8 Python files to fix pre-commit black formatting
- Update uv.lock to include scikit-learn and numpy dependencies

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
The uv.lock file was corrupted with a missing numpy==2.4.2 dependency
that scikit-learn requires. Regenerated the lock file from scratch to
properly resolve all dependencies including the new dev dependency on
scikit-learn for documentation testing.

Also applied code formatting with black to match project style.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Black reformatted 8 files to comply with code style standards.
Changes include improved string literal wrapping and function
call formatting for better readability.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Restructure documentation to align more with Ecologits

1 participant