godocmd

package module
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 9, 2025 License: MIT Imports: 8 Imported by: 0

README

CI Go Reference Go Version

godocmd

godocmd is a powerful Go documentation generator that outputs structured, customizable Markdown from your Go packages. It supports recursive package scanning, inclusion of private and undocumented symbols, and both CLI and programmatic usage.


🔧 Installation (CLI)

You can install the CLI tool using:

go install github.com/thinktide/godocmd/cmd@latest

This will install a binary named godocmd in your $GOBIN.


🚀 CLI Usage

godocmd -d <directory> [flags]
Common Flags:
Flag Alias Description
--dir -d Required. The root directory to scan for Go packages.
--out -o Output markdown file (defaults to stdout).
--recursive -r Recursively scan subdirectories.
--include-private -p Include unexported (private) functions and types.
--include-undocumented Include symbols that lack GoDoc comments.
--verbose Output detailed logs for each step.
Example
# Generate docs recursively from ./models and write to docs.md
godocmd -d ./models -r -o docs.md --include-private --verbose

📦 Programmatic Usage

You can also use godocmd as a Go library.

Install
go get github.com/thinktide/godocmd@latest
Import and Use
package main

import (
	"os"

	"github.com/thinktide/godocmd"
	"github.com/thinktide/godocmd/enums"
)

func main() {
	err := godocmd.GenerateMarkdown(
		"./myproject",   // root directory
		os.Stdout,       // output writer
		enums.Recursive, // enable recursion
		enums.Verbose,   // log verbosely
		enums.IncludePrivate, // include private symbols
	)
	if err != nil {
		panic(err)
	}
}

🧠 Features

  • ✅ Recursive scanning with enums.Recursive
  • ✅ Support for private types and functions via enums.IncludePrivate
  • ✅ Strict documentation enforcement (exclude symbols with no GoDoc by default)
  • ✅ Verbose logging support with enums.Verbose
  • ✅ Outputs Markdown suitable for GitHub, wikis, or README sections

📁 Output Structure

  • Each package starts with a comment header: <!-- ./package/path -->
  • Structs include:
    • Go struct definition
    • JSON tags (if present)
    • DynamoDB tags (if present)
  • Functions and methods show:
    • Full signature
    • GoDoc comments (if present)
    • Grouped under their receiver (for methods)

🧪 Contributing

We welcome issues and pull requests that improve Markdown output, formatting, or support for additional tag types (e.g., BSON, XML).


📄 License

This project is licensed under the MIT License.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateMarkdown

func GenerateMarkdown(rootDir string, out io.Writer, flags ...enums.MarkdownFlag) error

GenerateMarkdown recursively walks the provided directory and writes markdown documentation for each Go package to the given writer.

By default, it excludes non-exported (private) symbols and undocumented items. Behavior can be modified by passing any combination of flags from the enums package.

Parameters:

  • rootDir: The base directory to scan
  • out: The writer to output markdown to (e.g., os.Stdout or a file)
  • flags: One or more enums.MarkdownFlag values to alter generation behavior

Returns:

  • error: Any error encountered during parsing or output

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL