Skip to content

proposal: x/pkgsite: Enhancing with Markdown and Mermaid Diagram Support #70320

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

Closed
H0llyW00dzZ opened this issue Nov 13, 2024 · 2 comments
Closed
Labels
Milestone

Comments

@H0llyW00dzZ
Copy link

Proposal Details

Introduction

This proposal suggests enhancing the Go pkgsite documentation by adding support for Markdown rendering and Mermaid diagrams. This feature aims to improve the readability and visual appeal of Go documentation, making it easier for developers to understand complex processes through graphical representations.

Motivation

Currently, the Go pkgsite supports plain text documentation, which can limit the ability to convey complex ideas effectively. By integrating Markdown and Mermaid diagrams, we can:

  • Enhance the clarity of documentation.
  • Provide visual representations of algorithms and processes.
  • Improve the overall user experience for developers using Go packages.

Proposed Solution

The solution involves extending the pkgsite's documentation rendering capabilities to include:

  1. Markdown Support: Allowing developers to use Markdown syntax for formatting text, including headings, lists, code blocks, and more.

  2. Mermaid Diagram Support: Enabling the use of Mermaid syntax to create flowcharts, sequence diagrams, and other graphical representations directly within Go documentation comments.

Implementation Details

Markdown Support

  • Rendering Engine: Integrate a Markdown rendering engine into the pkgsite to parse and display formatted text.
  • Syntax: Support standard Markdown syntax, enabling features like bold, italics, lists, and code blocks.

Mermaid Diagram Support

  • Diagram Parsing: Incorporate a Mermaid parser to convert Mermaid syntax within comments into rendered diagrams.
  • Example Integration: Developers can include Mermaid diagrams in their code comments as shown below:
package docs

// Mermaid diagram:
//
// graph TD
//     A[Start] --> B[Set baseCount to 1]
//     B --> C[Set maxCount to 100000]
//     C --> D[For each key pattern]
//     D --> E[Initialize cursor to 0]
//     E --> F{Has cursor reached 0?}
//     F -- No --> G[Scan keys with current count]
//     G --> H{Performance check}
//     H -- Fast --> I[Double count]
//     H -- Slow --> J[Halve count]
//     I --> K{Is count > maxCount?}
//     K -- Yes --> L[Set count to maxCount]
//     K -- No --> M[Continue with current count]
//     J --> N{Is count < baseCount?}
//     N -- Yes --> O[Set count to baseCount]
//     N -- No --> M
//     M --> P[Delete found keys]
//     P --> E
//     F -- Yes --> Q[Move to next pattern]
//     Q --> D
//     D --> R[End]
  • Rendering Example: The above comment would render as:
Loading
graph TD
    A[Start] --> B[Set baseCount to 1]
    B --> C[Set maxCount to 100000]
    C --> D[For each key pattern]
    D --> E[Initialize cursor to 0]
    E --> F{Has cursor reached 0?}
    F -- No --> G[Scan keys with current count]
    G --> H{Performance check}
    H -- Fast --> I[Double count]
    H -- Slow --> J[Halve count]
    I --> K{Is count > maxCount?}
    K -- Yes --> L[Set count to maxCount]
    K -- No --> M[Continue with current count]
    J --> N{Is count < baseCount?}
    N -- Yes --> O[Set count to baseCount]
    N -- No --> M
    M --> P[Delete found keys]
    P --> E
    F -- Yes --> Q[Move to next pattern]
    Q --> D
    D --> R[End]

Benefits

  • Improved Comprehension: Visual aids can significantly enhance the understanding of complex logic.
  • Enhanced Documentation: Markdown allows for more structured and readable documentation.
  • Developer Engagement: Encourages developers to document their code more thoroughly with better tools.

Conclusion

Integrating Markdown and Mermaid diagram support into the Go pkgsite will modernize Go documentation, making it more effective and engaging. This enhancement aligns with the ongoing efforts to improve developer experience and code quality within the Go community.

@gabyhelp
Copy link

Related Issues

(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)

@gopherbot gopherbot added this to the Proposal milestone Nov 13, 2024
@seankhliao
Copy link
Member

Duplicate of #67339

@seankhliao seankhliao marked this as a duplicate of #67339 Nov 13, 2024
@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale Nov 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants