Table of Contents

Contributing to the documentation

Documentation lives in this repository, is reviewed in pull requests and is kept accurate by checks. This page explains how it is organized and how to add to it. For code contributions see CONTRIBUTING.md.

How the documentation is organized

The documentation follows the Diátaxis framework: four kinds of page that serve four different needs. Put a page in the folder that matches its purpose.

Folder Kind Purpose Write it as
getting-started/ Tutorial Learn by doing something that works end to end. A guided lesson with one path and the expected output.
how-to/ How-to guide Solve a specific task. Numbered or short steps for someone who already knows the basics.
reference/ Reference Look up exact facts. Complete, accurate, neutral tables with no tutorials.
explanation/ Explanation Understand how and why. Discussion and diagrams; no step lists.
decisions/ Decision records Preserve the reasons for design decisions. MADR records.

Rules for accurate pages

  1. Run what you document. Every code sample must have been compiled and run, and any output you show must be what the program printed. Copy defaults from the code (for example by printing new ReSettings()), not from memory or older docs.
  2. Describe behavior, then link. State a fact in one place and link to it from elsewhere, so there is one page to fix when behavior changes.
  3. Use the documented names. Use the class, property and setting names exactly as in the code. Use input1, input2 for default input names.
  4. Update docs with the code. A pull request that changes behavior updates the page that describes it, and adds an entry under [Unreleased] in CHANGELOG.md.
  5. Mark uncertainty. If you could not verify a statement, do not write it as a fact.

Style

  • Write in the present tense and the active voice. Address the reader as "you".
  • Keep sentences short, and put the most important fact first.
  • Give every fenced code block a language (csharp, json, shell, text, xml).
  • Give every image meaningful alt text.
  • Use sentence-case headings, with levels that increase one at a time.
  • Use relative links between pages in this folder, and check that they resolve.

Diagrams

Diagrams are written as Mermaid text in the page, so they are reviewed like code and render on GitHub. Put a marker comment directly above the fenced block:

<!-- diagram: evaluation-sequence -->
```mermaid
flowchart LR
    a --> b
```
  • The name (lowercase letters, digits and hyphens) must be unique. It becomes docs/images/diagrams/<name>.svg.
  • Put a one-line caption under the diagram, for example _Figure 1. What the diagram shows._
  • Use flowchart, sequenceDiagram or classDiagram. Avoid experimental diagram types and HTML labels, because the SVG export is used where Mermaid cannot render.
  • Keep diagrams small enough to read. Split a diagram that has more than about 15 nodes.

The SVG exports are committed (the NuGet package README embeds them, and nuget.org cannot render Mermaid). Regenerate them whenever a diagram changes:

cd scripts/diagrams
npm ci
# Use any Chromium-based browser, for example Edge or Chrome:
export PUPPETEER_EXECUTABLE_PATH="/path/to/chrome"      # PowerShell: $env:PUPPETEER_EXECUTABLE_PATH = "C:\path\to\msedge.exe"

npm run validate    # render every diagram to a temporary folder; fails on a Mermaid syntax error
npm run render      # write docs/images/diagrams/*.svg
npm run check       # no browser needed: every diagram has an up-to-date SVG and there are no orphans

Commit the changed .svg files together with the page.

Before you open a pull request

  • Run the code samples you added or changed.
  • Check every link and image path you added.
  • If you changed a diagram, run npm run render and npm run check.
  • Build the site with the strict commands below and fix every warning.
  • Add a CHANGELOG.md entry for user-visible behavior changes.

Building the documentation site

The site is generated with DocFX. It is pinned in .config/dotnet-tools.json, and the configuration is docs/docfx.json. The API reference is generated from the XML documentation comments in src/RulesEngine, so every public member needs one (a missing comment fails the library build).

dotnet tool restore
cd docs
dotnet docfx metadata docfx.json          # generates docs/api from the XML comments
dotnet docfx build docfx.json --warningsAsErrors   # builds docs/_site and fails on broken links or references
dotnet docfx serve _site                  # optional: browse the site at http://localhost:8080

docs/api and docs/_site are generated and are not committed. When you add a page, add it to the toc.yml of its folder.

Checks that run in CI

The docs workflow runs on every pull request and push to main that touches Markdown, docs/, src/ or the diagram tooling. All of it can be reproduced locally.

Check What it catches Run it locally
Markdown lint Broken link fragments and reference definitions, empty links, missing code-fence languages and image alt text, malformed tables, skipped heading levels. Configured in .markdownlint-cli2.jsonc. npx markdownlint-cli2 from the repository root
Diagram exports A Mermaid diagram changed without regenerating its SVG, or an orphaned SVG. node scripts/diagrams/render-diagrams.mjs --check
Local links A relative link to a file or a heading that does not exist. lychee --offline --include-fragments '**/*.md'
Site build Any DocFX warning: broken cross-references, invalid XML comments, missing pages. the two docfx commands above

A separate workflow, docs-external-links, checks every link to an external site once a week (and on demand), so a third-party outage cannot block a pull request. When it fails, fix the link, or exclude it in the workflow if the site only refuses automated requests.

Tests that keep the pages accurate

test/RulesEngine.UnitTest/DocumentationAccuracyTest.cs runs with the normal unit tests (the build workflow) and fails when a page disagrees with the code:

Test What it compares
ReSettingsReference_* The tables in docs/reference/resettings.md against ReSettings (every public setting, its type and its default) and against the NestedRuleExecutionMode enum.
ApiOverview_MentionsEveryMethodOfIRulesEngine docs/reference/api-overview.md against the members of IRulesEngine.
JsonExamplesInTheDocumentation_* Every ```json block that holds a workflow or a rule, in docs/, README.md and the package README, against the engine's workflow validation. A block may leave parts out with ...; otherwise it must be valid JSON.
DocumentedErrorMessages_* The message prefixes listed in docs/reference/error-handling.md against the messages the engine produces.

When one fails, either the code changed and the page did not, or the page is wrong: fix whichever is wrong. Do not edit the test to make it pass. New settings and new public methods need a row or an entry in the matching page in the same pull request.

Publishing the site (maintainers)

The docs workflow builds the site on every run and deploys it to GitHub Pages from main. The deploy step is off until a maintainer enables it once:

  1. In Settings > Pages, set Source to GitHub Actions. (It is currently Deploy from a branch, which serves the Jekyll theme from docs/.)
  2. In Settings > Secrets and variables > Actions > Variables, create the repository variable DOCS_DEPLOY with the value true.
  3. Run the docs workflow from the Actions tab (or push a docs change to main) and open the Pages URL from the deploy job.

To publish nothing again, delete the variable or set it to anything other than true.