Skip to content

feat(docs): embed markdown guides in Scalar API reference#3453

Merged
PierreBrisorgueil merged 3 commits intomasterfrom
feat/scalar-markdown-guides
Apr 10, 2026
Merged

feat(docs): embed markdown guides in Scalar API reference#3453
PierreBrisorgueil merged 3 commits intomasterfrom
feat/scalar-markdown-guides

Conversation

@PierreBrisorgueil
Copy link
Copy Markdown
Contributor

@PierreBrisorgueil PierreBrisorgueil commented Apr 10, 2026

Summary

  • What changed: Support per-module markdown guides under modules/*/doc/guides/*.md, merged into the OpenAPI spec's info.description so Scalar renders them in its sidebar next to the API reference. Migrated the 3 guides previously shipped by the Vue docs module (getting-started, authentication, organizations) into modules/core/doc/guides/.
  • Why: API documentation belongs with the API. This makes the Node API the single source of truth for docs and lets any module ship its own long-form guides automatically.
  • Related issues: Closes feat(docs): embed markdown guides in Scalar API reference #3451

Scope

  • Module(s) impacted: core (guides), lib/helpers/guides.js, lib/services/express.js, config/assets.js
  • Cross-module impact: none — guides are discovered by glob, any module can drop a doc/guides/*.md file and it will appear
  • Risk level: low — purely additive, only affects /api/docs rendering

Merge approach

Scalar renders the OpenAPI info.description as an "Introduction" section and splits on markdown H1/H2 for sidebar navigation. Each loaded guide is injected as a top-level # Title block into info.description, so each guide becomes its own sidebar entry. Guides are:

  • discovered by a new allGuides asset pattern (modules/*/doc/guides/*.md)
  • filtered / sorted alphabetically for deterministic ordering across OSes
  • resilient to unreadable or empty files (skipped with a warning, never throws)
  • merged into a spec-level info.description, preserving any existing intro text

Placed the migrated guides under modules/core/doc/guides/ so they are always active regardless of downstream module activation (core is never filtered out).

Validation

  • npm run lint
  • npm run test:coverage — 763/763 tests pass, lib/helpers/guides.js at 100% lines
  • New unit tests cover: title derivation, H1 stripping, real-file loading + sorting, empty input, missing files, empty-body skip, description merging, preserving existing description, no-op cases, non-object spec guard
  • New initSwagger test verifies guides are merged into the served spec via /api/spec.json

Guardrails check

  • No secrets or credentials introduced
  • No risky rename/move of core stack paths
  • Changes remain merge-friendly for downstream projects (purely additive glob + helper)
  • Tests added when behavior changed

Notes for reviewers

  • Adding a new modules/{name}/doc/guides/foo.md file automatically makes "Foo" appear in the Scalar sidebar on next restart — no registration needed
  • Vue-side removal of the old docs module is handled in a separate PR
  • The guide files deliberately avoid domain-specific content so downstream projects inherit them cleanly

Summary by CodeRabbit

  • New Features
    • Integrated three comprehensive guides directly into the API reference documentation:
      • Getting Started: local setup instructions and health verification
      • Authentication: JWT workflows including signup, login, token refresh, and password reset
      • Organizations: creation, member management, and role-based access control

Add support for per-module markdown guides discovered via
`modules/*/doc/guides/*.md` globbing. Guides are merged into the
OpenAPI spec's `info.description` so Scalar renders them as sidebar
sections alongside the API reference.

Migrates the 3 guides previously shipped by the Vue docs module
(getting-started, authentication, organizations) under
`modules/core/doc/guides/` so they are always active regardless of
downstream project configuration.

Closes #3451
@PierreBrisorgueil PierreBrisorgueil added the Feat A new feature label Apr 10, 2026
@PierreBrisorgueil PierreBrisorgueil self-assigned this Apr 10, 2026
@PierreBrisorgueil PierreBrisorgueil added the Feat A new feature label Apr 10, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 10, 2026

Warning

Rate limit exceeded

@PierreBrisorgueil has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 13 minutes and 34 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 13 minutes and 34 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: bc47faae-88d9-4aa8-8dd1-b8393b2cbfd1

📥 Commits

Reviewing files that changed from the base of the PR and between ab0e6a9 and f2fc611.

📒 Files selected for processing (6)
  • config/index.js
  • lib/helpers/config.js
  • modules/core/doc/guides/authentication.md
  • modules/core/doc/guides/getting-started.md
  • modules/core/doc/guides/organizations.md
  • modules/core/tests/core.integration.tests.js

Walkthrough

The changes implement a markdown guide loading system that discovers guide files from modules/*/doc/guides/*.md, processes them into normalized structures, and merges their content into the OpenAPI spec's info.description field for display in the Scalar API reference. Three initial guides (authentication, getting-started, organizations) are included.

Changes

Cohort / File(s) Summary
Asset and Configuration
config/assets.js, lib/helpers/config.js
Added new allGuides glob pattern and initialized files.guides configuration to discover markdown guide files across modules.
Guide Helper Utilities
lib/helpers/guides.js
New module exporting functions to: extract human-readable titles from file paths, strip leading H1 headers from markdown, load guide files with error resilience and alphabetical sorting, and merge guides into OpenAPI spec's info.description.
Express Integration
lib/services/express.js
Integrated guide loading and merging into Swagger/OpenAPI initialization flow within initSwagger to append guides to spec before serving at /api/spec.json.
Documentation Guides
modules/core/doc/guides/authentication.md, modules/core/doc/guides/getting-started.md, modules/core/doc/guides/organizations.md
Added three markdown guides covering JWT authentication workflows, local development setup, and organization/role-based access control features.
Test Coverage
modules/core/tests/core.unit.tests.js
Updated asset configuration expectations and added comprehensive test suites for guides helper functions (title derivation, H1 stripping, file loading with error handling, spec merging) and end-to-end Swagger initialization behavior.

Sequence Diagram(s)

sequenceDiagram
    participant Express Server
    participant Config
    participant Guides Helper
    participant OpenAPI Spec
    participant Scalar Frontend

    Express Server->>Config: Load configuration with assets glob
    Config->>Config: Glob modules/*/doc/guides/*.md
    Config->>Guides Helper: Initialize with guide file paths
    
    Guides Helper->>Guides Helper: Load each guide file (with error handling)
    Guides Helper->>Guides Helper: Strip H1 headers, derive titles, sort alphabetically
    
    Guides Helper->>OpenAPI Spec: Merge guides into info.description
    OpenAPI Spec->>OpenAPI Spec: Append guide titles and bodies with separators
    
    Express Server->>Express Server: Serve merged spec at /api/spec.json
    Scalar Frontend->>Express Server: Request spec
    Express Server->>Scalar Frontend: Return spec with embedded guides
    Scalar Frontend->>Scalar Frontend: Render guides in sidebar alongside OpenAPI reference
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: embedding markdown guides into the Scalar API reference documentation system.
Description check ✅ Passed The PR description follows the template closely with all key sections: Summary (what, why), Scope (modules, cross-module impact, risk), Merge approach details, comprehensive Validation, Guardrails checks, and Notes for reviewers.
Linked Issues check ✅ Passed The changeset fully implements #3451 requirements: per-module guides glob pattern added, guides merged into OpenAPI spec info.description, three legacy guides migrated, config and express.js updated, and comprehensive tests added.
Out of Scope Changes check ✅ Passed All code changes are directly related to the objectives: asset glob pattern, guide loader/merger utilities, integration into express spec serving, three guide documentation files, and corresponding tests.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/scalar-markdown-guides

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@PierreBrisorgueil PierreBrisorgueil marked this pull request as ready for review April 10, 2026 12:24
Copilot AI review requested due to automatic review settings April 10, 2026 12:24
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 10, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.73%. Comparing base (46e7534) to head (f2fc611).
⚠️ Report is 7 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3453      +/-   ##
==========================================
+ Coverage   85.58%   85.73%   +0.15%     
==========================================
  Files         113      114       +1     
  Lines        2878     2910      +32     
  Branches      796      804       +8     
==========================================
+ Hits         2463     2495      +32     
  Misses        329      329              
  Partials       86       86              

☔ 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.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds support for embedding per-module markdown guides into the OpenAPI spec so Scalar (/api/docs) can render long-form documentation alongside the API reference, and migrates initial core guides into the Node backend.

Changes:

  • Add a new lib/helpers/guides.js helper to load/sort markdown guides and merge them into spec.info.description.
  • Extend config assets + global file discovery to include modules/*/doc/guides/*.md, and wire guide merging into initSwagger.
  • Add unit tests covering guide loading/merging and swagger serving behavior, and introduce three starter guides under modules/core/doc/guides/.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
modules/core/tests/core.unit.tests.js Adds tests for guide helper behavior and for swagger spec serving with merged guides.
modules/core/doc/guides/authentication.md New authentication guide content intended for Scalar sidebar.
modules/core/doc/guides/getting-started.md New getting-started guide content intended for Scalar sidebar.
modules/core/doc/guides/organizations.md New organizations guide content intended for Scalar sidebar.
lib/services/express.js Loads guides from config.files.guides and merges into the served OpenAPI spec.
lib/helpers/guides.js New helper to load/normalize markdown guides and append them to info.description.
lib/helpers/config.js Adds files.guides discovery via assets.allGuides.
config/assets.js Introduces allGuides glob pattern for guide discovery.

@PierreBrisorgueil
Copy link
Copy Markdown
Contributor Author

@coderabbitai full review

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 10, 2026

✅ Actions performed

Full review triggered.

- Auth guide uses cookie-based JWT (TOKEN cookie), no refresh token
- Fix password reset payload (newPassword instead of password)
- Organizations: /invites route and currentOrganization + /switch
  (not the X-Organization-Id header)
- getting-started prerequisite bumped to Node 22+
- Include guides in module-activation filtering (fileKeys)
- Expand initGlobalConfigFiles JSDoc
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
lib/helpers/config.js (1)

141-155: 🛠️ Refactor suggestion | 🟠 Major

Add full JSDoc tags to modified initGlobalConfigFiles.

Line 144 modifies initGlobalConfigFiles, but its header is missing @param and @returns.

✍️ Proposed doc-only fix
 /**
- * Initialize global configuration files
+ * Initialize global configuration files.
+ * `@param` {object} assets - Glob patterns configuration from `config/assets.js`.
+ * `@returns` {Promise<object>} Resolved file groups keyed by asset type.
  */
 const initGlobalConfigFiles = async (assets) => {

As per coding guidelines: **/*.js: Every new or modified function must have a JSDoc header: one-line description, @param for each argument, @returns for any non-void return value.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@lib/helpers/config.js` around lines 141 - 155, The function
initGlobalConfigFiles is missing a JSDoc header; add a one-line description plus
JSDoc tags: include `@param` {Object} assets - input asset globs (describe keys
like allYaml, allGuides, mongooseModels, preRoutes, routes, config, policies)
and `@returns` {Promise<Object>} - resolved object containing swagger, guides,
mongooseModels, preRoutes, routes, configs, and policies; place this JSDoc
immediately above the initGlobalConfigFiles declaration so it documents that
function and its return value.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@modules/core/tests/core.unit.tests.js`:
- Around line 613-632: Add an integration test in
modules/core/tests/core.integration.tests.js that boots the app (or http server)
and verifies the expressService.initSwagger behavior end-to-end: send an HTTP
GET to /api/spec.json and assert the returned JSON has info.description as a
string that contains the rendered guide content (e.g., '# Getting Started' and
'Your first API call'), and also hit /api/docs to ensure the docs endpoint is
reachable; reuse the same fixtures/paths used in the unit test and ensure the
app is started/stopped within the test lifecycle so the guide merge behavior
exercised by expressService.initSwagger is validated in an integration scenario.

---

Outside diff comments:
In `@lib/helpers/config.js`:
- Around line 141-155: The function initGlobalConfigFiles is missing a JSDoc
header; add a one-line description plus JSDoc tags: include `@param` {Object}
assets - input asset globs (describe keys like allYaml, allGuides,
mongooseModels, preRoutes, routes, config, policies) and `@returns`
{Promise<Object>} - resolved object containing swagger, guides, mongooseModels,
preRoutes, routes, configs, and policies; place this JSDoc immediately above the
initGlobalConfigFiles declaration so it documents that function and its return
value.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: fe808fb9-edf7-470f-8061-fc903add330f

📥 Commits

Reviewing files that changed from the base of the PR and between c5aae01 and ab0e6a9.

📒 Files selected for processing (8)
  • config/assets.js
  • lib/helpers/config.js
  • lib/helpers/guides.js
  • lib/services/express.js
  • modules/core/doc/guides/authentication.md
  • modules/core/doc/guides/getting-started.md
  • modules/core/doc/guides/organizations.md
  • modules/core/tests/core.unit.tests.js

- Verify /api/spec.json exposes merged markdown guides in
  info.description (Getting Started, Authentication, Organizations)
- Verify /api/docs serves the Scalar HTML reference page
@PierreBrisorgueil PierreBrisorgueil merged commit 67acceb into master Apr 10, 2026
5 checks passed
@PierreBrisorgueil PierreBrisorgueil deleted the feat/scalar-markdown-guides branch April 10, 2026 13:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feat A new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(docs): embed markdown guides in Scalar API reference

2 participants