diff --git a/README.md b/README.md index 0df74e0..ed01465 100644 --- a/README.md +++ b/README.md @@ -230,15 +230,15 @@ Know of another project that is using gomarkdoc? Open an issue with a descriptio ## Index - [type Renderer](<#Renderer>) - - [func NewRenderer(opts ...RendererOption) (*Renderer, error)](<#NewRenderer>) - - [func (out *Renderer) Example(ex *lang.Example) (string, error)](<#Renderer.Example>) - - [func (out *Renderer) File(file *lang.File) (string, error)](<#Renderer.File>) - - [func (out *Renderer) Func(fn *lang.Func) (string, error)](<#Renderer.Func>) - - [func (out *Renderer) Package(pkg *lang.Package) (string, error)](<#Renderer.Package>) - - [func (out *Renderer) Type(typ *lang.Type) (string, error)](<#Renderer.Type>) + - [func NewRenderer\(opts ...RendererOption\) \(\*Renderer, error\)](<#NewRenderer>) + - [func \(out \*Renderer\) Example\(ex \*lang.Example\) \(string, error\)](<#Renderer.Example>) + - [func \(out \*Renderer\) File\(file \*lang.File\) \(string, error\)](<#Renderer.File>) + - [func \(out \*Renderer\) Func\(fn \*lang.Func\) \(string, error\)](<#Renderer.Func>) + - [func \(out \*Renderer\) Package\(pkg \*lang.Package\) \(string, error\)](<#Renderer.Package>) + - [func \(out \*Renderer\) Type\(typ \*lang.Type\) \(string, error\)](<#Renderer.Type>) - [type RendererOption](<#RendererOption>) - - [func WithFormat(format format.Format) RendererOption](<#WithFormat>) - - [func WithTemplateOverride(name, tmpl string) RendererOption](<#WithTemplateOverride>) + - [func WithFormat\(format format.Format\) RendererOption](<#WithFormat>) + - [func WithTemplateOverride\(name, tmpl string\) RendererOption](<#WithTemplateOverride>) diff --git a/format/README.md b/format/README.md index 24059a4..fcd3d55 100755 --- a/format/README.md +++ b/format/README.md @@ -13,57 +13,57 @@ Each of the formats in this package contains the same set of formatting function ## Index - [type AzureDevOpsMarkdown](<#AzureDevOpsMarkdown>) - - [func (f *AzureDevOpsMarkdown) Accordion(title, body string) (string, error)](<#AzureDevOpsMarkdown.Accordion>) - - [func (f *AzureDevOpsMarkdown) AccordionHeader(title string) (string, error)](<#AzureDevOpsMarkdown.AccordionHeader>) - - [func (f *AzureDevOpsMarkdown) AccordionTerminator() (string, error)](<#AzureDevOpsMarkdown.AccordionTerminator>) - - [func (f *AzureDevOpsMarkdown) Anchor(anchor string) string](<#AzureDevOpsMarkdown.Anchor>) - - [func (f *AzureDevOpsMarkdown) AnchorHeader(level int, text, anchor string) (string, error)](<#AzureDevOpsMarkdown.AnchorHeader>) - - [func (f *AzureDevOpsMarkdown) Bold(text string) (string, error)](<#AzureDevOpsMarkdown.Bold>) - - [func (f *AzureDevOpsMarkdown) CodeBlock(language, code string) (string, error)](<#AzureDevOpsMarkdown.CodeBlock>) - - [func (f *AzureDevOpsMarkdown) CodeHref(loc lang.Location) (string, error)](<#AzureDevOpsMarkdown.CodeHref>) - - [func (f *AzureDevOpsMarkdown) Escape(text string) string](<#AzureDevOpsMarkdown.Escape>) - - [func (f *AzureDevOpsMarkdown) Header(level int, text string) (string, error)](<#AzureDevOpsMarkdown.Header>) - - [func (f *AzureDevOpsMarkdown) Link(text, href string) (string, error)](<#AzureDevOpsMarkdown.Link>) - - [func (f *AzureDevOpsMarkdown) ListEntry(depth int, text string) (string, error)](<#AzureDevOpsMarkdown.ListEntry>) - - [func (f *AzureDevOpsMarkdown) LocalHref(headerText string) (string, error)](<#AzureDevOpsMarkdown.LocalHref>) - - [func (f *AzureDevOpsMarkdown) RawAnchorHeader(level int, text, anchor string) (string, error)](<#AzureDevOpsMarkdown.RawAnchorHeader>) - - [func (f *AzureDevOpsMarkdown) RawHeader(level int, text string) (string, error)](<#AzureDevOpsMarkdown.RawHeader>) - - [func (f *AzureDevOpsMarkdown) RawLocalHref(anchor string) string](<#AzureDevOpsMarkdown.RawLocalHref>) + - [func \(f \*AzureDevOpsMarkdown\) Accordion\(title, body string\) \(string, error\)](<#AzureDevOpsMarkdown.Accordion>) + - [func \(f \*AzureDevOpsMarkdown\) AccordionHeader\(title string\) \(string, error\)](<#AzureDevOpsMarkdown.AccordionHeader>) + - [func \(f \*AzureDevOpsMarkdown\) AccordionTerminator\(\) \(string, error\)](<#AzureDevOpsMarkdown.AccordionTerminator>) + - [func \(f \*AzureDevOpsMarkdown\) Anchor\(anchor string\) string](<#AzureDevOpsMarkdown.Anchor>) + - [func \(f \*AzureDevOpsMarkdown\) AnchorHeader\(level int, text, anchor string\) \(string, error\)](<#AzureDevOpsMarkdown.AnchorHeader>) + - [func \(f \*AzureDevOpsMarkdown\) Bold\(text string\) \(string, error\)](<#AzureDevOpsMarkdown.Bold>) + - [func \(f \*AzureDevOpsMarkdown\) CodeBlock\(language, code string\) \(string, error\)](<#AzureDevOpsMarkdown.CodeBlock>) + - [func \(f \*AzureDevOpsMarkdown\) CodeHref\(loc lang.Location\) \(string, error\)](<#AzureDevOpsMarkdown.CodeHref>) + - [func \(f \*AzureDevOpsMarkdown\) Escape\(text string\) string](<#AzureDevOpsMarkdown.Escape>) + - [func \(f \*AzureDevOpsMarkdown\) Header\(level int, text string\) \(string, error\)](<#AzureDevOpsMarkdown.Header>) + - [func \(f \*AzureDevOpsMarkdown\) Link\(text, href string\) \(string, error\)](<#AzureDevOpsMarkdown.Link>) + - [func \(f \*AzureDevOpsMarkdown\) ListEntry\(depth int, text string\) \(string, error\)](<#AzureDevOpsMarkdown.ListEntry>) + - [func \(f \*AzureDevOpsMarkdown\) LocalHref\(headerText string\) \(string, error\)](<#AzureDevOpsMarkdown.LocalHref>) + - [func \(f \*AzureDevOpsMarkdown\) RawAnchorHeader\(level int, text, anchor string\) \(string, error\)](<#AzureDevOpsMarkdown.RawAnchorHeader>) + - [func \(f \*AzureDevOpsMarkdown\) RawHeader\(level int, text string\) \(string, error\)](<#AzureDevOpsMarkdown.RawHeader>) + - [func \(f \*AzureDevOpsMarkdown\) RawLocalHref\(anchor string\) string](<#AzureDevOpsMarkdown.RawLocalHref>) - [type Format](<#Format>) - [type GitHubFlavoredMarkdown](<#GitHubFlavoredMarkdown>) - - [func (f *GitHubFlavoredMarkdown) Accordion(title, body string) (string, error)](<#GitHubFlavoredMarkdown.Accordion>) - - [func (f *GitHubFlavoredMarkdown) AccordionHeader(title string) (string, error)](<#GitHubFlavoredMarkdown.AccordionHeader>) - - [func (f *GitHubFlavoredMarkdown) AccordionTerminator() (string, error)](<#GitHubFlavoredMarkdown.AccordionTerminator>) - - [func (f *GitHubFlavoredMarkdown) Anchor(anchor string) string](<#GitHubFlavoredMarkdown.Anchor>) - - [func (f *GitHubFlavoredMarkdown) AnchorHeader(level int, text, anchor string) (string, error)](<#GitHubFlavoredMarkdown.AnchorHeader>) - - [func (f *GitHubFlavoredMarkdown) Bold(text string) (string, error)](<#GitHubFlavoredMarkdown.Bold>) - - [func (f *GitHubFlavoredMarkdown) CodeBlock(language, code string) (string, error)](<#GitHubFlavoredMarkdown.CodeBlock>) - - [func (f *GitHubFlavoredMarkdown) CodeHref(loc lang.Location) (string, error)](<#GitHubFlavoredMarkdown.CodeHref>) - - [func (f *GitHubFlavoredMarkdown) Escape(text string) string](<#GitHubFlavoredMarkdown.Escape>) - - [func (f *GitHubFlavoredMarkdown) Header(level int, text string) (string, error)](<#GitHubFlavoredMarkdown.Header>) - - [func (f *GitHubFlavoredMarkdown) Link(text, href string) (string, error)](<#GitHubFlavoredMarkdown.Link>) - - [func (f *GitHubFlavoredMarkdown) ListEntry(depth int, text string) (string, error)](<#GitHubFlavoredMarkdown.ListEntry>) - - [func (f *GitHubFlavoredMarkdown) LocalHref(headerText string) (string, error)](<#GitHubFlavoredMarkdown.LocalHref>) - - [func (f *GitHubFlavoredMarkdown) RawAnchorHeader(level int, text, anchor string) (string, error)](<#GitHubFlavoredMarkdown.RawAnchorHeader>) - - [func (f *GitHubFlavoredMarkdown) RawHeader(level int, text string) (string, error)](<#GitHubFlavoredMarkdown.RawHeader>) - - [func (f *GitHubFlavoredMarkdown) RawLocalHref(anchor string) string](<#GitHubFlavoredMarkdown.RawLocalHref>) + - [func \(f \*GitHubFlavoredMarkdown\) Accordion\(title, body string\) \(string, error\)](<#GitHubFlavoredMarkdown.Accordion>) + - [func \(f \*GitHubFlavoredMarkdown\) AccordionHeader\(title string\) \(string, error\)](<#GitHubFlavoredMarkdown.AccordionHeader>) + - [func \(f \*GitHubFlavoredMarkdown\) AccordionTerminator\(\) \(string, error\)](<#GitHubFlavoredMarkdown.AccordionTerminator>) + - [func \(f \*GitHubFlavoredMarkdown\) Anchor\(anchor string\) string](<#GitHubFlavoredMarkdown.Anchor>) + - [func \(f \*GitHubFlavoredMarkdown\) AnchorHeader\(level int, text, anchor string\) \(string, error\)](<#GitHubFlavoredMarkdown.AnchorHeader>) + - [func \(f \*GitHubFlavoredMarkdown\) Bold\(text string\) \(string, error\)](<#GitHubFlavoredMarkdown.Bold>) + - [func \(f \*GitHubFlavoredMarkdown\) CodeBlock\(language, code string\) \(string, error\)](<#GitHubFlavoredMarkdown.CodeBlock>) + - [func \(f \*GitHubFlavoredMarkdown\) CodeHref\(loc lang.Location\) \(string, error\)](<#GitHubFlavoredMarkdown.CodeHref>) + - [func \(f \*GitHubFlavoredMarkdown\) Escape\(text string\) string](<#GitHubFlavoredMarkdown.Escape>) + - [func \(f \*GitHubFlavoredMarkdown\) Header\(level int, text string\) \(string, error\)](<#GitHubFlavoredMarkdown.Header>) + - [func \(f \*GitHubFlavoredMarkdown\) Link\(text, href string\) \(string, error\)](<#GitHubFlavoredMarkdown.Link>) + - [func \(f \*GitHubFlavoredMarkdown\) ListEntry\(depth int, text string\) \(string, error\)](<#GitHubFlavoredMarkdown.ListEntry>) + - [func \(f \*GitHubFlavoredMarkdown\) LocalHref\(headerText string\) \(string, error\)](<#GitHubFlavoredMarkdown.LocalHref>) + - [func \(f \*GitHubFlavoredMarkdown\) RawAnchorHeader\(level int, text, anchor string\) \(string, error\)](<#GitHubFlavoredMarkdown.RawAnchorHeader>) + - [func \(f \*GitHubFlavoredMarkdown\) RawHeader\(level int, text string\) \(string, error\)](<#GitHubFlavoredMarkdown.RawHeader>) + - [func \(f \*GitHubFlavoredMarkdown\) RawLocalHref\(anchor string\) string](<#GitHubFlavoredMarkdown.RawLocalHref>) - [type PlainMarkdown](<#PlainMarkdown>) - - [func (f *PlainMarkdown) Accordion(title, body string) (string, error)](<#PlainMarkdown.Accordion>) - - [func (f *PlainMarkdown) AccordionHeader(title string) (string, error)](<#PlainMarkdown.AccordionHeader>) - - [func (f *PlainMarkdown) AccordionTerminator() (string, error)](<#PlainMarkdown.AccordionTerminator>) - - [func (f *PlainMarkdown) Anchor(anchor string) string](<#PlainMarkdown.Anchor>) - - [func (f *PlainMarkdown) AnchorHeader(level int, text, anchor string) (string, error)](<#PlainMarkdown.AnchorHeader>) - - [func (f *PlainMarkdown) Bold(text string) (string, error)](<#PlainMarkdown.Bold>) - - [func (f *PlainMarkdown) CodeBlock(language, code string) (string, error)](<#PlainMarkdown.CodeBlock>) - - [func (f *PlainMarkdown) CodeHref(loc lang.Location) (string, error)](<#PlainMarkdown.CodeHref>) - - [func (f *PlainMarkdown) Escape(text string) string](<#PlainMarkdown.Escape>) - - [func (f *PlainMarkdown) Header(level int, text string) (string, error)](<#PlainMarkdown.Header>) - - [func (f *PlainMarkdown) Link(text, href string) (string, error)](<#PlainMarkdown.Link>) - - [func (f *PlainMarkdown) ListEntry(depth int, text string) (string, error)](<#PlainMarkdown.ListEntry>) - - [func (f *PlainMarkdown) LocalHref(headerText string) (string, error)](<#PlainMarkdown.LocalHref>) - - [func (f *PlainMarkdown) RawAnchorHeader(level int, text, anchor string) (string, error)](<#PlainMarkdown.RawAnchorHeader>) - - [func (f *PlainMarkdown) RawHeader(level int, text string) (string, error)](<#PlainMarkdown.RawHeader>) - - [func (f *PlainMarkdown) RawLocalHref(anchor string) string](<#PlainMarkdown.RawLocalHref>) + - [func \(f \*PlainMarkdown\) Accordion\(title, body string\) \(string, error\)](<#PlainMarkdown.Accordion>) + - [func \(f \*PlainMarkdown\) AccordionHeader\(title string\) \(string, error\)](<#PlainMarkdown.AccordionHeader>) + - [func \(f \*PlainMarkdown\) AccordionTerminator\(\) \(string, error\)](<#PlainMarkdown.AccordionTerminator>) + - [func \(f \*PlainMarkdown\) Anchor\(anchor string\) string](<#PlainMarkdown.Anchor>) + - [func \(f \*PlainMarkdown\) AnchorHeader\(level int, text, anchor string\) \(string, error\)](<#PlainMarkdown.AnchorHeader>) + - [func \(f \*PlainMarkdown\) Bold\(text string\) \(string, error\)](<#PlainMarkdown.Bold>) + - [func \(f \*PlainMarkdown\) CodeBlock\(language, code string\) \(string, error\)](<#PlainMarkdown.CodeBlock>) + - [func \(f \*PlainMarkdown\) CodeHref\(loc lang.Location\) \(string, error\)](<#PlainMarkdown.CodeHref>) + - [func \(f \*PlainMarkdown\) Escape\(text string\) string](<#PlainMarkdown.Escape>) + - [func \(f \*PlainMarkdown\) Header\(level int, text string\) \(string, error\)](<#PlainMarkdown.Header>) + - [func \(f \*PlainMarkdown\) Link\(text, href string\) \(string, error\)](<#PlainMarkdown.Link>) + - [func \(f \*PlainMarkdown\) ListEntry\(depth int, text string\) \(string, error\)](<#PlainMarkdown.ListEntry>) + - [func \(f \*PlainMarkdown\) LocalHref\(headerText string\) \(string, error\)](<#PlainMarkdown.LocalHref>) + - [func \(f \*PlainMarkdown\) RawAnchorHeader\(level int, text, anchor string\) \(string, error\)](<#PlainMarkdown.RawAnchorHeader>) + - [func \(f \*PlainMarkdown\) RawHeader\(level int, text string\) \(string, error\)](<#PlainMarkdown.RawHeader>) + - [func \(f \*PlainMarkdown\) RawLocalHref\(anchor string\) string](<#PlainMarkdown.RawLocalHref>) diff --git a/format/formatcore/README.md b/format/formatcore/README.md index eb8277b..620d0ae 100755 --- a/format/formatcore/README.md +++ b/format/formatcore/README.md @@ -10,19 +10,19 @@ Package formatcore provides utilities for creating formatters like those found i ## Index -- [func Anchor(anchor string) string](<#Anchor>) -- [func AnchorHeader(level int, text, anchor string) (string, error)](<#AnchorHeader>) -- [func Bold(text string) string](<#Bold>) -- [func CodeBlock(code string) string](<#CodeBlock>) -- [func Escape(text string) string](<#Escape>) -- [func GFMAccordion(title, body string) string](<#GFMAccordion>) -- [func GFMAccordionHeader(title string) string](<#GFMAccordionHeader>) -- [func GFMAccordionTerminator() string](<#GFMAccordionTerminator>) -- [func GFMCodeBlock(language, code string) string](<#GFMCodeBlock>) -- [func Header(level int, text string) (string, error)](<#Header>) -- [func Link(text, href string) string](<#Link>) -- [func ListEntry(depth int, text string) string](<#ListEntry>) -- [func PlainText(text string) string](<#PlainText>) +- [func Anchor\(anchor string\) string](<#Anchor>) +- [func AnchorHeader\(level int, text, anchor string\) \(string, error\)](<#AnchorHeader>) +- [func Bold\(text string\) string](<#Bold>) +- [func CodeBlock\(code string\) string](<#CodeBlock>) +- [func Escape\(text string\) string](<#Escape>) +- [func GFMAccordion\(title, body string\) string](<#GFMAccordion>) +- [func GFMAccordionHeader\(title string\) string](<#GFMAccordionHeader>) +- [func GFMAccordionTerminator\(\) string](<#GFMAccordionTerminator>) +- [func GFMCodeBlock\(language, code string\) string](<#GFMCodeBlock>) +- [func Header\(level int, text string\) \(string, error\)](<#Header>) +- [func Link\(text, href string\) string](<#Link>) +- [func ListEntry\(depth int, text string\) string](<#ListEntry>) +- [func PlainText\(text string\) string](<#PlainText>) diff --git a/format/formatcore/base.go b/format/formatcore/base.go index 5772cd3..fea1066 100644 --- a/format/formatcore/base.go +++ b/format/formatcore/base.go @@ -98,7 +98,7 @@ func Link(text, href string) string { return text } - return fmt.Sprintf("[%s](<%s>)", text, href) + return fmt.Sprintf("[%s](<%s>)", Escape(text), href) } // ListEntry generates an unordered list entry with the provided text at the diff --git a/lang/README.md b/lang/README.md index baa2c17..7213f7f 100644 --- a/lang/README.md +++ b/lang/README.md @@ -10,118 +10,118 @@ Package lang provides constructs for defining golang language constructs and ext ## Index -- [func PackageSymbols(pkg *doc.Package) map[string]Symbol](<#PackageSymbols>) +- [func PackageSymbols\(pkg \*doc.Package\) map\[string\]Symbol](<#PackageSymbols>) - [type Block](<#Block>) - - [func NewBlock(cfg *Config, kind BlockKind, spans []*Span, inline bool) *Block](<#NewBlock>) - - [func NewListBlock(cfg *Config, list *List, inline bool) *Block](<#NewListBlock>) - - [func ParseBlocks(cfg *Config, blocks []comment.Block, inline bool) []*Block](<#ParseBlocks>) - - [func (b *Block) Inline() bool](<#Block.Inline>) - - [func (b *Block) Kind() BlockKind](<#Block.Kind>) - - [func (b *Block) Level() int](<#Block.Level>) - - [func (b *Block) List() *List](<#Block.List>) - - [func (b *Block) Spans() []*Span](<#Block.Spans>) + - [func NewBlock\(cfg \*Config, kind BlockKind, spans \[\]\*Span, inline bool\) \*Block](<#NewBlock>) + - [func NewListBlock\(cfg \*Config, list \*List, inline bool\) \*Block](<#NewListBlock>) + - [func ParseBlocks\(cfg \*Config, blocks \[\]comment.Block, inline bool\) \[\]\*Block](<#ParseBlocks>) + - [func \(b \*Block\) Inline\(\) bool](<#Block.Inline>) + - [func \(b \*Block\) Kind\(\) BlockKind](<#Block.Kind>) + - [func \(b \*Block\) Level\(\) int](<#Block.Level>) + - [func \(b \*Block\) List\(\) \*List](<#Block.List>) + - [func \(b \*Block\) Spans\(\) \[\]\*Span](<#Block.Spans>) - [type BlockKind](<#BlockKind>) - [type Config](<#Config>) - - [func NewConfig(log logger.Logger, workDir string, pkgDir string, opts ...ConfigOption) (*Config, error)](<#NewConfig>) - - [func (c *Config) Inc(step int) *Config](<#Config.Inc>) + - [func NewConfig\(log logger.Logger, workDir string, pkgDir string, opts ...ConfigOption\) \(\*Config, error\)](<#NewConfig>) + - [func \(c \*Config\) Inc\(step int\) \*Config](<#Config.Inc>) - [type ConfigOption](<#ConfigOption>) - - [func ConfigWithRepoOverrides(overrides *Repo) ConfigOption](<#ConfigWithRepoOverrides>) + - [func ConfigWithRepoOverrides\(overrides \*Repo\) ConfigOption](<#ConfigWithRepoOverrides>) - [type Doc](<#Doc>) - - [func NewDoc(cfg *Config, text string) *Doc](<#NewDoc>) - - [func (d *Doc) Blocks() []*Block](<#Doc.Blocks>) - - [func (d *Doc) Level() int](<#Doc.Level>) + - [func NewDoc\(cfg \*Config, text string\) \*Doc](<#NewDoc>) + - [func \(d \*Doc\) Blocks\(\) \[\]\*Block](<#Doc.Blocks>) + - [func \(d \*Doc\) Level\(\) int](<#Doc.Level>) - [type Example](<#Example>) - - [func NewExample(cfg *Config, name string, doc *doc.Example) *Example](<#NewExample>) - - [func (ex *Example) Code() (string, error)](<#Example.Code>) - - [func (ex *Example) Doc() *Doc](<#Example.Doc>) - - [func (ex *Example) HasOutput() bool](<#Example.HasOutput>) - - [func (ex *Example) Level() int](<#Example.Level>) - - [func (ex *Example) Location() Location](<#Example.Location>) - - [func (ex *Example) Name() string](<#Example.Name>) - - [func (ex *Example) Output() string](<#Example.Output>) - - [func (ex *Example) Summary() string](<#Example.Summary>) - - [func (ex *Example) Title() string](<#Example.Title>) + - [func NewExample\(cfg \*Config, name string, doc \*doc.Example\) \*Example](<#NewExample>) + - [func \(ex \*Example\) Code\(\) \(string, error\)](<#Example.Code>) + - [func \(ex \*Example\) Doc\(\) \*Doc](<#Example.Doc>) + - [func \(ex \*Example\) HasOutput\(\) bool](<#Example.HasOutput>) + - [func \(ex \*Example\) Level\(\) int](<#Example.Level>) + - [func \(ex \*Example\) Location\(\) Location](<#Example.Location>) + - [func \(ex \*Example\) Name\(\) string](<#Example.Name>) + - [func \(ex \*Example\) Output\(\) string](<#Example.Output>) + - [func \(ex \*Example\) Summary\(\) string](<#Example.Summary>) + - [func \(ex \*Example\) Title\(\) string](<#Example.Title>) - [type File](<#File>) - - [func NewFile(header, footer string, packages []*Package) *File](<#NewFile>) + - [func NewFile\(header, footer string, packages \[\]\*Package\) \*File](<#NewFile>) - [type Func](<#Func>) - - [func NewFunc(cfg *Config, doc *doc.Func, examples []*doc.Example) *Func](<#NewFunc>) - - [func (fn *Func) Anchor() string](<#Func.Anchor>) - - [func (fn *Func) Doc() *Doc](<#Func.Doc>) - - [func (fn *Func) Examples() (examples []*Example)](<#Func.Examples>) - - [func (fn *Func) Level() int](<#Func.Level>) - - [func (fn *Func) Location() Location](<#Func.Location>) - - [func (fn *Func) Name() string](<#Func.Name>) - - [func (fn *Func) Receiver() string](<#Func.Receiver>) - - [func (fn *Func) Signature() (string, error)](<#Func.Signature>) - - [func (fn *Func) Summary() string](<#Func.Summary>) - - [func (fn *Func) Title() string](<#Func.Title>) + - [func NewFunc\(cfg \*Config, doc \*doc.Func, examples \[\]\*doc.Example\) \*Func](<#NewFunc>) + - [func \(fn \*Func\) Anchor\(\) string](<#Func.Anchor>) + - [func \(fn \*Func\) Doc\(\) \*Doc](<#Func.Doc>) + - [func \(fn \*Func\) Examples\(\) \(examples \[\]\*Example\)](<#Func.Examples>) + - [func \(fn \*Func\) Level\(\) int](<#Func.Level>) + - [func \(fn \*Func\) Location\(\) Location](<#Func.Location>) + - [func \(fn \*Func\) Name\(\) string](<#Func.Name>) + - [func \(fn \*Func\) Receiver\(\) string](<#Func.Receiver>) + - [func \(fn \*Func\) Signature\(\) \(string, error\)](<#Func.Signature>) + - [func \(fn \*Func\) Summary\(\) string](<#Func.Summary>) + - [func \(fn \*Func\) Title\(\) string](<#Func.Title>) - [type Item](<#Item>) - - [func NewItem(cfg *Config, docItem *comment.ListItem) *Item](<#NewItem>) - - [func (i *Item) Blocks() []*Block](<#Item.Blocks>) - - [func (i *Item) Kind() ItemKind](<#Item.Kind>) - - [func (i *Item) Number() int](<#Item.Number>) + - [func NewItem\(cfg \*Config, docItem \*comment.ListItem\) \*Item](<#NewItem>) + - [func \(i \*Item\) Blocks\(\) \[\]\*Block](<#Item.Blocks>) + - [func \(i \*Item\) Kind\(\) ItemKind](<#Item.Kind>) + - [func \(i \*Item\) Number\(\) int](<#Item.Number>) - [type ItemKind](<#ItemKind>) - [type List](<#List>) - - [func NewList(cfg *Config, docList *comment.List) *List](<#NewList>) - - [func (l *List) BlankBetween() bool](<#List.BlankBetween>) - - [func (l *List) Items() []*Item](<#List.Items>) + - [func NewList\(cfg \*Config, docList \*comment.List\) \*List](<#NewList>) + - [func \(l \*List\) BlankBetween\(\) bool](<#List.BlankBetween>) + - [func \(l \*List\) Items\(\) \[\]\*Item](<#List.Items>) - [type Location](<#Location>) - - [func NewLocation(cfg *Config, node ast.Node) Location](<#NewLocation>) + - [func NewLocation\(cfg \*Config, node ast.Node\) Location](<#NewLocation>) - [type Package](<#Package>) - - [func NewPackage(cfg *Config, examples []*doc.Example) *Package](<#NewPackage>) - - [func NewPackageFromBuild(log logger.Logger, pkg *build.Package, opts ...PackageOption) (*Package, error)](<#NewPackageFromBuild>) - - [func (pkg *Package) Consts() (consts []*Value)](<#Package.Consts>) - - [func (pkg *Package) Dir() string](<#Package.Dir>) - - [func (pkg *Package) Dirname() string](<#Package.Dirname>) - - [func (pkg *Package) Doc() *Doc](<#Package.Doc>) - - [func (pkg *Package) Examples() (examples []*Example)](<#Package.Examples>) - - [func (pkg *Package) Funcs() (funcs []*Func)](<#Package.Funcs>) - - [func (pkg *Package) Import() string](<#Package.Import>) - - [func (pkg *Package) ImportPath() string](<#Package.ImportPath>) - - [func (pkg *Package) Level() int](<#Package.Level>) - - [func (pkg *Package) Name() string](<#Package.Name>) - - [func (pkg *Package) Summary() string](<#Package.Summary>) - - [func (pkg *Package) Types() (types []*Type)](<#Package.Types>) - - [func (pkg *Package) Vars() (vars []*Value)](<#Package.Vars>) + - [func NewPackage\(cfg \*Config, examples \[\]\*doc.Example\) \*Package](<#NewPackage>) + - [func NewPackageFromBuild\(log logger.Logger, pkg \*build.Package, opts ...PackageOption\) \(\*Package, error\)](<#NewPackageFromBuild>) + - [func \(pkg \*Package\) Consts\(\) \(consts \[\]\*Value\)](<#Package.Consts>) + - [func \(pkg \*Package\) Dir\(\) string](<#Package.Dir>) + - [func \(pkg \*Package\) Dirname\(\) string](<#Package.Dirname>) + - [func \(pkg \*Package\) Doc\(\) \*Doc](<#Package.Doc>) + - [func \(pkg \*Package\) Examples\(\) \(examples \[\]\*Example\)](<#Package.Examples>) + - [func \(pkg \*Package\) Funcs\(\) \(funcs \[\]\*Func\)](<#Package.Funcs>) + - [func \(pkg \*Package\) Import\(\) string](<#Package.Import>) + - [func \(pkg \*Package\) ImportPath\(\) string](<#Package.ImportPath>) + - [func \(pkg \*Package\) Level\(\) int](<#Package.Level>) + - [func \(pkg \*Package\) Name\(\) string](<#Package.Name>) + - [func \(pkg \*Package\) Summary\(\) string](<#Package.Summary>) + - [func \(pkg \*Package\) Types\(\) \(types \[\]\*Type\)](<#Package.Types>) + - [func \(pkg \*Package\) Vars\(\) \(vars \[\]\*Value\)](<#Package.Vars>) - [type PackageOption](<#PackageOption>) - - [func PackageWithRepositoryOverrides(repo *Repo) PackageOption](<#PackageWithRepositoryOverrides>) - - [func PackageWithUnexportedIncluded() PackageOption](<#PackageWithUnexportedIncluded>) + - [func PackageWithRepositoryOverrides\(repo \*Repo\) PackageOption](<#PackageWithRepositoryOverrides>) + - [func PackageWithUnexportedIncluded\(\) PackageOption](<#PackageWithUnexportedIncluded>) - [type PackageOptions](<#PackageOptions>) - [type Position](<#Position>) - [type Repo](<#Repo>) - [type Span](<#Span>) - - [func NewSpan(cfg *Config, kind SpanKind, text string, url string) *Span](<#NewSpan>) - - [func ParseSpans(cfg *Config, texts []comment.Text) []*Span](<#ParseSpans>) - - [func (s *Span) Kind() SpanKind](<#Span.Kind>) - - [func (s *Span) Text() string](<#Span.Text>) - - [func (s *Span) URL() string](<#Span.URL>) + - [func NewSpan\(cfg \*Config, kind SpanKind, text string, url string\) \*Span](<#NewSpan>) + - [func ParseSpans\(cfg \*Config, texts \[\]comment.Text\) \[\]\*Span](<#ParseSpans>) + - [func \(s \*Span\) Kind\(\) SpanKind](<#Span.Kind>) + - [func \(s \*Span\) Text\(\) string](<#Span.Text>) + - [func \(s \*Span\) URL\(\) string](<#Span.URL>) - [type SpanKind](<#SpanKind>) - [type Symbol](<#Symbol>) - - [func (s Symbol) Anchor() string](<#Symbol.Anchor>) + - [func \(s Symbol\) Anchor\(\) string](<#Symbol.Anchor>) - [type SymbolKind](<#SymbolKind>) - [type Type](<#Type>) - - [func NewType(cfg *Config, doc *doc.Type, examples []*doc.Example) *Type](<#NewType>) - - [func (typ *Type) Anchor() string](<#Type.Anchor>) - - [func (typ *Type) Consts() []*Value](<#Type.Consts>) - - [func (typ *Type) Decl() (string, error)](<#Type.Decl>) - - [func (typ *Type) Doc() *Doc](<#Type.Doc>) - - [func (typ *Type) Examples() (examples []*Example)](<#Type.Examples>) - - [func (typ *Type) Funcs() []*Func](<#Type.Funcs>) - - [func (typ *Type) Level() int](<#Type.Level>) - - [func (typ *Type) Location() Location](<#Type.Location>) - - [func (typ *Type) Methods() []*Func](<#Type.Methods>) - - [func (typ *Type) Name() string](<#Type.Name>) - - [func (typ *Type) Summary() string](<#Type.Summary>) - - [func (typ *Type) Title() string](<#Type.Title>) - - [func (typ *Type) Vars() []*Value](<#Type.Vars>) + - [func NewType\(cfg \*Config, doc \*doc.Type, examples \[\]\*doc.Example\) \*Type](<#NewType>) + - [func \(typ \*Type\) Anchor\(\) string](<#Type.Anchor>) + - [func \(typ \*Type\) Consts\(\) \[\]\*Value](<#Type.Consts>) + - [func \(typ \*Type\) Decl\(\) \(string, error\)](<#Type.Decl>) + - [func \(typ \*Type\) Doc\(\) \*Doc](<#Type.Doc>) + - [func \(typ \*Type\) Examples\(\) \(examples \[\]\*Example\)](<#Type.Examples>) + - [func \(typ \*Type\) Funcs\(\) \[\]\*Func](<#Type.Funcs>) + - [func \(typ \*Type\) Level\(\) int](<#Type.Level>) + - [func \(typ \*Type\) Location\(\) Location](<#Type.Location>) + - [func \(typ \*Type\) Methods\(\) \[\]\*Func](<#Type.Methods>) + - [func \(typ \*Type\) Name\(\) string](<#Type.Name>) + - [func \(typ \*Type\) Summary\(\) string](<#Type.Summary>) + - [func \(typ \*Type\) Title\(\) string](<#Type.Title>) + - [func \(typ \*Type\) Vars\(\) \[\]\*Value](<#Type.Vars>) - [type Value](<#Value>) - - [func NewValue(cfg *Config, doc *doc.Value) *Value](<#NewValue>) - - [func (v *Value) Anchor() string](<#Value.Anchor>) - - [func (v *Value) Decl() (string, error)](<#Value.Decl>) - - [func (v *Value) Doc() *Doc](<#Value.Doc>) - - [func (v *Value) Level() int](<#Value.Level>) - - [func (v *Value) Location() Location](<#Value.Location>) - - [func (v *Value) Summary() string](<#Value.Summary>) + - [func NewValue\(cfg \*Config, doc \*doc.Value\) \*Value](<#NewValue>) + - [func \(v \*Value\) Anchor\(\) string](<#Value.Anchor>) + - [func \(v \*Value\) Decl\(\) \(string, error\)](<#Value.Decl>) + - [func \(v \*Value\) Doc\(\) \*Doc](<#Value.Doc>) + - [func \(v \*Value\) Level\(\) int](<#Value.Level>) + - [func \(v \*Value\) Location\(\) Location](<#Value.Location>) + - [func \(v \*Value\) Summary\(\) string](<#Value.Summary>) diff --git a/testData/docs/README.md b/testData/docs/README.md index 29abb5f..5fe3dfb 100644 --- a/testData/docs/README.md +++ b/testData/docs/README.md @@ -67,12 +67,12 @@ We also have constants like [Constant](<#Constant>) and [Const1](<#Const1>) plus - [Constants](<#constants>) - [Variables](<#variables>) -- [func Func(param int) int](<#Func>) +- [func Func\(param int\) int](<#Func>) - [type AnotherStruct](<#AnotherStruct>) - - [func NewAnotherStruct() *AnotherStruct](<#NewAnotherStruct>) - - [func (s *AnotherStruct) GetField() string](<#AnotherStruct.GetField>) + - [func NewAnotherStruct\(\) \*AnotherStruct](<#NewAnotherStruct>) + - [func \(s \*AnotherStruct\) GetField\(\) string](<#AnotherStruct.GetField>) - [type Type](<#Type>) - - [func (t *Type) Func()](<#Type.Func>) + - [func \(t \*Type\) Func\(\)](<#Type.Func>) ## Constants @@ -123,7 +123,7 @@ Func is present in this file. ## type [AnotherStruct]() -AnotherStruct has methods like [\*AnotherStruct.GetField](<#AnotherStruct.GetField>) and also has an initializer called [NewAnotherStruct](<#NewAnotherStruct>). +AnotherStruct has methods like [\\\*AnotherStruct.GetField](<#AnotherStruct.GetField>) and also has an initializer called [NewAnotherStruct](<#NewAnotherStruct>). ```go type AnotherStruct struct { @@ -138,7 +138,7 @@ type AnotherStruct struct { func NewAnotherStruct() *AnotherStruct ``` -NewAnotherStruct\(\) makes [\*AnotherStruct](<#AnotherStruct>). +NewAnotherStruct\(\) makes [\\\*AnotherStruct](<#AnotherStruct>). ### func \(\*AnotherStruct\) [GetField]() diff --git a/testData/embed/README.md b/testData/embed/README.md index 4be9859..2dcd392 100644 --- a/testData/embed/README.md +++ b/testData/embed/README.md @@ -14,7 +14,7 @@ Package embed tests out embedding of documentation in an existing readme. ## Index -- [func EmbeddedFunc(param int) int](<#EmbeddedFunc>) +- [func EmbeddedFunc\(param int\) int](<#EmbeddedFunc>) @@ -47,7 +47,7 @@ Package embed tests out embedding of documentation in an existing readme. ## Index -- [func EmbeddedFunc(param int) int](<#EmbeddedFunc>) +- [func EmbeddedFunc\(param int\) int](<#EmbeddedFunc>) @@ -80,7 +80,7 @@ Package embed tests out embedding of documentation in an existing readme. ## Index -- [func EmbeddedFunc(param int) int](<#EmbeddedFunc>) +- [func EmbeddedFunc\(param int\) int](<#EmbeddedFunc>) diff --git a/testData/generics/README.md b/testData/generics/README.md new file mode 100644 index 0000000..27e4aa2 --- /dev/null +++ b/testData/generics/README.md @@ -0,0 +1,55 @@ + + +# generics + +```go +import "github.com/princjef/gomarkdoc/testData/generics" +``` + +## Index + +- [func Func\[S int | float64\]\(s S\) S](<#Func>) +- [type Generic](<#Generic>) + - [func NewGeneric\[T any\]\(param T\) Generic\[T\]](<#NewGeneric>) + - [func \(g Generic\[T\]\) Method\(\)](<#Generic[T].Method>) + + + +## func [Func]() + +```go +func Func[S int | float64](s S) S +``` + +Func is a generic function. + + +## type [Generic]() + +Generic is a generic struct. + +```go +type Generic[T any] struct { + Field T +} +``` + + +### func [NewGeneric]() + +```go +func NewGeneric[T any](param T) Generic[T] +``` + +NewGeneric produces a new [Generic](<#Generic>) struct. + + +### func \(Generic\[T\]\) [Method]() + +```go +func (g Generic[T]) Method() +``` + +Method is a method of a generic type. + +Generated by [gomarkdoc]() diff --git a/testData/generics/generics.go b/testData/generics/generics.go new file mode 100644 index 0000000..1dc7cf7 --- /dev/null +++ b/testData/generics/generics.go @@ -0,0 +1,19 @@ +package generics + +// Generic is a generic struct. +type Generic[T any] struct { + Field T +} + +// NewGeneric produces a new [Generic] struct. +func NewGeneric[T any](param T) Generic[T] { + return Generic[T]{Field: param} +} + +// Method is a method of a generic type. +func (g Generic[T]) Method() {} + +// Func is a generic function. +func Func[S int | float64](s S) S { + return s +} diff --git a/testData/lang/function/README.md b/testData/lang/function/README.md index 50b4963..9e34416 100644 --- a/testData/lang/function/README.md +++ b/testData/lang/function/README.md @@ -10,13 +10,13 @@ import "github.com/princjef/gomarkdoc/testData/lang/function" - [Constants](<#constants>) - [Variables](<#variables>) -- [func Standalone(p1 int, p2 string) (int, error)](<#Standalone>) +- [func Standalone\(p1 int, p2 string\) \(int, error\)](<#Standalone>) - [type Generic](<#Generic>) - - [func (r Generic[T]) WithGenericReceiver()](<#Generic[T].WithGenericReceiver>) + - [func \(r Generic\[T\]\) WithGenericReceiver\(\)](<#Generic[T].WithGenericReceiver>) - [type Receiver](<#Receiver>) - - [func New() Receiver](<#New>) - - [func (r *Receiver) WithPtrReceiver()](<#Receiver.WithPtrReceiver>) - - [func (r Receiver) WithReceiver()](<#Receiver.WithReceiver>) + - [func New\(\) Receiver](<#New>) + - [func \(r \*Receiver\) WithPtrReceiver\(\)](<#Receiver.WithPtrReceiver>) + - [func \(r Receiver\) WithReceiver\(\)](<#Receiver.WithReceiver>) ## Constants diff --git a/testData/nested/README.md b/testData/nested/README.md index afef288..e4941e9 100755 --- a/testData/nested/README.md +++ b/testData/nested/README.md @@ -8,7 +8,7 @@ import "github.com/princjef/gomarkdoc/testData/nested" ## Index -- [func Parent() int](<#Parent>) +- [func Parent\(\) int](<#Parent>) diff --git a/testData/nested/inner/README.md b/testData/nested/inner/README.md index da48ecb..1cc5ed6 100755 --- a/testData/nested/inner/README.md +++ b/testData/nested/inner/README.md @@ -8,7 +8,7 @@ import "github.com/princjef/gomarkdoc/testData/nested/inner" ## Index -- [func Child() int](<#Child>) +- [func Child\(\) int](<#Child>) diff --git a/testData/simple/README.md b/testData/simple/README.md index 2e954f6..2fc6aa9 100755 --- a/testData/simple/README.md +++ b/testData/simple/README.md @@ -11,8 +11,8 @@ Package simple contains, some simple code to exercise basic scenarios for docume ## Index - [type Num](<#Num>) - - [func AddNums(num1, num2 Num) Num](<#AddNums>) - - [func (n Num) Add(num Num) Num](<#Num.Add>) + - [func AddNums\(num1, num2 Num\) Num](<#AddNums>) + - [func \(n Num\) Add\(num Num\) Num](<#Num.Add>) diff --git a/testData/tags/README.md b/testData/tags/README.md index 3bbead3..eb74b01 100755 --- a/testData/tags/README.md +++ b/testData/tags/README.md @@ -10,8 +10,8 @@ Package tags contains code to demonstrate usage of build tags. ## Index -- [func Tagged() int](<#Tagged>) -- [func Untagged() int](<#Untagged>) +- [func Tagged\(\) int](<#Tagged>) +- [func Untagged\(\) int](<#Untagged>) diff --git a/testData/unexported/README.md b/testData/unexported/README.md index 10fe16e..8c1c65b 100755 --- a/testData/unexported/README.md +++ b/testData/unexported/README.md @@ -11,9 +11,9 @@ Package unexported contains some simple code to exercise basic scenarios for doc ## Index - [type Num](<#Num>) - - [func AddNums(num1, num2 Num) Num](<#AddNums>) - - [func addInternal(num1, num2 Num) Num](<#addInternal>) - - [func (n Num) Add(num Num) Num](<#Num.Add>) + - [func AddNums\(num1, num2 Num\) Num](<#AddNums>) + - [func addInternal\(num1, num2 Num\) Num](<#addInternal>) + - [func \(n Num\) Add\(num Num\) Num](<#Num.Add>) diff --git a/testData/untagged/README.md b/testData/untagged/README.md index 5ca4f59..2aa063c 100755 --- a/testData/untagged/README.md +++ b/testData/untagged/README.md @@ -10,7 +10,7 @@ Package untagged contains code to demonstrate usage of build tags. ## Index -- [func Untagged() int](<#Untagged>) +- [func Untagged\(\) int](<#Untagged>)