This document outlines the documentation standards for the Markdown Previewer project. All contributors should follow these guidelines to ensure consistent, thorough documentation.
-
Package Documentation
- Every package must have a package comment, a block comment preceding the package clause
- Package comments should provide information about the package's purpose and usage
// Package parser provides utilities for parsing markdown content // and converting it to HTML for preview purposes. package parser
-
Exported Functions, Types, and Methods
- All exported (capitalized) elements must have a comment
- Comments should start with the element name
- Include information about parameters, return values, and any error conditions
// ParseMarkdown converts markdown content to HTML. It accepts a byte slice // containing markdown content and returns the HTML representation. // If parsing fails, an error will be returned. func ParseMarkdown(content []byte) ([]byte, error) {
-
Non-exported Elements
- Document non-exported elements that are complex or not immediately obvious
- Focus on explaining "why" rather than "what"
-
Examples
- Provide examples for complex functionality using Go's example testing framework
- Ensure examples are clear and demonstrate typical usage
-
Write Clear, Concise Comments
- Focus on why code exists rather than what it does
- Explain anything that isn't obvious from the code itself
-
Keep Comments Current
- Update comments when code changes
- Outdated comments are worse than no comments
-
Use Complete Sentences
- Start with capital letters
- End with periods
- Use proper grammar
The README should include:
-
Project Overview
- Clear description of what the project does
- Key features
-
Installation Instructions
- Step-by-step guide for installing the project
- Any prerequisites
-
Usage Examples
- Basic usage examples with code and screenshots
- Common command-line options
-
Configuration
- Available configuration options
- Example configuration
-
Contributing
- How to contribute to the project
- Development setup instructions
-
License Information
- Include license details or reference to LICENSE file
-
SECURITY.md
- Security considerations
- Reporting vulnerabilities
-
CHANGELOG.md
- Track changes between versions
- Follow semantic versioning principles
-
API Documentation
- Document any APIs provided by the application
- Include endpoint descriptions, parameters, and responses
Before committing code, ensure documentation:
- Exists for all exported elements
- Is clear and grammatically correct
- Is up-to-date with current code behavior
- Includes examples where appropriate
- Mentions error conditions and edge cases
- Is consistent in tone and style
-
Tools
- Use
go doc
to review documentation - Run
golint
to catch undocumented exports - Consider
godocdown
for generating markdown from Go docs
- Use
-
Standards
- Follow Go's official documentation style
- Use present tense ("Gets" not "Get")
- Be consistent with formatting
- Update documentation as part of the same commit that changes code
- Include documentation updates in pull request descriptions
- Request documentation review as part of code review
- Do not merge code with incomplete or outdated documentation