Skip to content

docs(typed-express-router): Refactor documentation into Diátaxis Reference section #1041

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 24, 2025

Conversation

youngjungithub
Copy link
Contributor

This PR significantly restructures and enhances the documentation for the @api-ts/typed-express-router package by adopting the Diátaxis framework and creating a dedicated, multi-file Reference section.

Motivation:

The previous documentation, primarily located in the README, mixed introductory guides with technical details. This made it difficult for users to quickly find precise information about specific functions, types, or configuration options without reading through narrative content. A formal Reference section, following Diátaxis principles, provides a much clearer, more accessible, and maintainable structure for technical documentation.

Changes Implemented:

  1. Diátaxis Reference Structure: Established a dedicated directory (docs/reference/typed-express-router/) for technical reference material, separating it from other documentation types (like Tutorials or How-To Guides, which might exist elsewhere).
  2. Component-Focused File Organization: Divided the reference documentation into distinct MDX files, each dedicated to a specific component or concept of the library:
    • index.mdx: Serves as the entry point and overview for the typed-express-router reference section.
    • create-router.mdx: Details the createRouter function.
    • wrap-router.mdx: Details the wrapRouter function.
    • typed-router.mdx: Describes the TypedRouter object itself, including its typed route methods (e.g., .get, .getUnchecked) and middleware handling (.use).
    • request-response.mdx: Explains the augmented req (with req.decoded) and res (with res.sendEncoded) objects provided to route handlers.
    • configuration.mdx: Documents the global (TypedRouterOptions) and per-route (RouteOptions) configuration, including error hooks (onDecodeError, onEncodeError), the post-response hook (afterEncodedResponseSent), and routeAliases.
    • typed-request-handler.mdx: Describes the TypedRequestHandler helper type for improved type safety in handler definitions.
  3. Content Migration & Refinement: Technical information previously embedded in the README's "Usage" section has been extracted, expanded, and reformatted into precise reference documentation within the new structure. This includes:
    • Clear function/type signatures.
    • Detailed descriptions of parameters and return values.
    • Explicit explanations of component behavior (e.g., checked vs. unchecked routes, hook triggering conditions).
    • Code examples focused on illustrating the specific component being documented.

Benefits (Impact on Users & Maintainers):

  • Improved Discoverability: Users needing technical details about createRouter, req.decoded, configuration hooks, or other specific features can now find dedicated pages quickly.
  • Enhanced Clarity & Precision: Technical specifications are presented directly and unambiguously, separate from introductory narratives.
  • Better Maintainability: Isolating documentation for each component makes future updates easier and less error-prone.
  • Standardized Structure: Adopts a recognized documentation pattern (Diátaxis), improving consistency potentially across multiple related packages.
  • Increased Comprehensiveness: Provides more explicit detail on the library's features and types than previously available in the consolidated README.

This refactoring represents a significant improvement in the quality, usability, and maintainability of the @api-ts/typed-express-router technical documentation.

…rence section

This commit significantly restructures and enhances the documentation for the `@api-ts/typed-express-router` package by adopting the Diátaxis framework and creating a dedicated, multi-file Reference section.

**Motivation:**

The previous documentation, primarily located in the README, mixed introductory guides with technical details. This made it difficult for users to quickly find precise information about specific functions, types, or configuration options without reading through narrative content. A formal Reference section, following Diátaxis principles, provides a much clearer, more accessible, and maintainable structure for technical documentation.

**Changes Implemented:**

1.  **Diátaxis Reference Structure:** Established a dedicated directory (`docs/reference/typed-express-router/`) for technical reference material, separating it from other documentation types (like Tutorials or How-To Guides, which might exist elsewhere).
2.  **Component-Focused File Organization:** Divided the reference documentation into distinct MDX files, each dedicated to a specific component or concept of the library:
    * `index.mdx`: Serves as the entry point and overview for the typed-express-router reference section.
    * `create-router.mdx`: Details the `createRouter` function.
    * `wrap-router.mdx`: Details the `wrapRouter` function.
    * `typed-router.mdx`: Describes the `TypedRouter` object itself, including its typed route methods (e.g., `.get`, `.getUnchecked`) and middleware handling (`.use`).
    * `request-response.mdx`: Explains the augmented `req` (with `req.decoded`) and `res` (with `res.sendEncoded`) objects provided to route handlers.
    * `configuration.mdx`: Documents the global (`TypedRouterOptions`) and per-route (`RouteOptions`) configuration, including error hooks (`onDecodeError`, `onEncodeError`), the post-response hook (`afterEncodedResponseSent`), and `routeAliases`.
    * `typed-request-handler.mdx`: Describes the `TypedRequestHandler` helper type for improved type safety in handler definitions.
3.  **Content Migration & Refinement:** Technical information previously embedded in the README's "Usage" section has been extracted, expanded, and reformatted into precise reference documentation within the new structure. This includes:
    * Clear function/type signatures.
    * Detailed descriptions of parameters and return values.
    * Explicit explanations of component behavior (e.g., checked vs. unchecked routes, hook triggering conditions).
    * Code examples focused on illustrating the specific component being documented.

**Benefits (Impact on Users & Maintainers):**

* **Improved Discoverability:** Users needing technical details about `createRouter`, `req.decoded`, configuration hooks, or other specific features can now find dedicated pages quickly.
* **Enhanced Clarity & Precision:** Technical specifications are presented directly and unambiguously, separate from introductory narratives.
* **Better Maintainability:** Isolating documentation for each component makes future updates easier and less error-prone.
* **Standardized Structure:** Adopts a recognized documentation pattern (Diátaxis), improving consistency potentially across multiple related packages.
* **Increased Comprehensiveness:** Provides more explicit detail on the library's features and types than previously available in the consolidated README.

This refactoring represents a significant improvement in the quality, usability, and maintainability of the `@api-ts/typed-express-router` technical documentation.
@youngjungithub youngjungithub requested review from a team as code owners April 24, 2025 19:39
Copy link
Contributor

@vmccarty vmccarty left a comment

Choose a reason for hiding this comment

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

LGTM

@omeradeel26 omeradeel26 merged commit 6bdd8b4 into master Apr 24, 2025
11 checks passed
@omeradeel26 omeradeel26 deleted the docs/typed-router-cleanup branch April 24, 2025 20:14
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.

3 participants