gocomment

package
v0.41.6 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package gocomment turns OpenAPI description text into Go comment lines.

Descriptions are CommonMark and often carry inline HTML. Go comments are plain text, so markup is translated to readable text: links keep their text and absolute target, line-break tags become paragraph breaks, and other tags and emphasis markers are removed. Paragraphs are wrapped to a fixed width so generated comments read like hand-written ones.

Index

Constants

View Source
const Width = 76

Width is the preferred maximum length of comment text on one line. Words longer than the width, such as URLs, are never split.

Variables

This section is empty.

Functions

func Lines

func Lines(text string) []string

Lines returns text as comment lines without comment markers. Paragraphs are wrapped to Width and separated by an empty string. It returns nil when text holds nothing printable.

func Write

func Write(b *strings.Builder, indent string, lines []string)

Write appends lines to b as Go line comments, each starting with indent. An empty line becomes a bare comment marker.

Types

This section is empty.

Jump to

Keyboard shortcuts

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