Skip to content

Commit

Permalink
feat: add support for links in documentation (#89)
Browse files Browse the repository at this point in the history
  • Loading branch information
princjef authored Apr 2, 2023
1 parent 7d0c2ca commit cc78abb
Show file tree
Hide file tree
Showing 38 changed files with 1,516 additions and 478 deletions.
48 changes: 29 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import "github.com/princjef/gomarkdoc"
```

Package gomarkdoc formats documentation for one or more packages as markdown for usage outside of the main https://pkg.go.dev site. It supports custom templates for tweaking representation of documentation at fine\-grained levels, exporting both exported and unexported symbols, and custom formatters for different backends.
Package gomarkdoc formats documentation for one or more packages as markdown for usage outside of the main https://pkg.go.dev[https://pkg.go.dev](<https://pkg.go.dev>) site. It supports custom templates for tweaking representation of documentation at fine\-grained levels, exporting both exported and unexported symbols, and custom formatters for different backends.

### Command Line Usage

Expand Down Expand Up @@ -100,7 +100,7 @@ The documentation information that is output is formatted using a series of text

- index: generates an index of symbols within a package, similar to what is seen for godoc.org. The index links to types, funcs, variables, and constants generated by other templates, so it may need to be overridden as well if any of those templates are changed in a material way.

- example: generates documentation for a single example for a package or one of its symbols. The example is generated alongside whichever symbol it represents, based on the standard naming conventions outlined in https://blog.golang.org/examples#TOC_4 .
- example: generates documentation for a single example for a package or one of its symbols. The example is generated alongside whichever symbol it represents, based on the standard naming conventions outlined in https://blog.golang.org/examples#TOC_4[https://blog.golang.org/examples#TOC_4](<https://blog.golang.org/examples#TOC_4>).

- doc: generates the freeform documentation block for any of the above structures that can contain a documentation section.

Expand Down Expand Up @@ -229,18 +229,19 @@ Know of another project that is using gomarkdoc? Open an issue with a descriptio

## Index

- [type Renderer](<#type-renderer>)
- [func NewRenderer(opts ...RendererOption) (*Renderer, error)](<#func-newrenderer>)
- [func (out *Renderer) Example(ex *lang.Example) (string, error)](<#func-renderer-example>)
- [func (out *Renderer) File(file *lang.File) (string, error)](<#func-renderer-file>)
- [func (out *Renderer) Func(fn *lang.Func) (string, error)](<#func-renderer-func>)
- [func (out *Renderer) Package(pkg *lang.Package) (string, error)](<#func-renderer-package>)
- [func (out *Renderer) Type(typ *lang.Type) (string, error)](<#func-renderer-type>)
- [type RendererOption](<#type-rendereroption>)
- [func WithFormat(format format.Format) RendererOption](<#func-withformat>)
- [func WithTemplateOverride(name, tmpl string) RendererOption](<#func-withtemplateoverride>)
- [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>)
- [type RendererOption](<#RendererOption>)
- [func WithFormat(format format.Format) RendererOption](<#WithFormat>)
- [func WithTemplateOverride(name, tmpl string) RendererOption](<#WithTemplateOverride>)


<a name="Renderer"></a>
## type [Renderer](<https://github.com/princjef/gomarkdoc/blob/master/renderer.go#L16-L20>)

Renderer provides capabilities for rendering various types of documentation with the configured format and templates.
Expand All @@ -251,6 +252,7 @@ type Renderer struct {
}
```

<a name="NewRenderer"></a>
### func [NewRenderer](<https://github.com/princjef/gomarkdoc/blob/master/renderer.go#L31>)

```go
Expand All @@ -259,46 +261,52 @@ func NewRenderer(opts ...RendererOption) (*Renderer, error)

NewRenderer initializes a Renderer configured using the provided options. If nothing special is provided, the created renderer will use the default set of templates and the GitHubFlavoredMarkdown.

### func \(\*Renderer\) [Example](<https://github.com/princjef/gomarkdoc/blob/master/renderer.go#L181>)
<a name="Renderer.Example"></a>
### func \(\*Renderer\) [Example](<https://github.com/princjef/gomarkdoc/blob/master/renderer.go#L184>)

```go
func (out *Renderer) Example(ex *lang.Example) (string, error)
```

Example renders an example's documentation to a string. You can change the rendering of the example by overriding the "example" template or one of the templates it references.

### func \(\*Renderer\) [File](<https://github.com/princjef/gomarkdoc/blob/master/renderer.go#L153>)
<a name="Renderer.File"></a>
### func \(\*Renderer\) [File](<https://github.com/princjef/gomarkdoc/blob/master/renderer.go#L156>)

```go
func (out *Renderer) File(file *lang.File) (string, error)
```

File renders a file containing one or more packages to document to a string. You can change the rendering of the file by overriding the "file" template or one of the templates it references.

### func \(\*Renderer\) [Func](<https://github.com/princjef/gomarkdoc/blob/master/renderer.go#L167>)
<a name="Renderer.Func"></a>
### func \(\*Renderer\) [Func](<https://github.com/princjef/gomarkdoc/blob/master/renderer.go#L170>)

```go
func (out *Renderer) Func(fn *lang.Func) (string, error)
```

Func renders a function's documentation to a string. You can change the rendering of the package by overriding the "func" template or one of the templates it references.

### func \(\*Renderer\) [Package](<https://github.com/princjef/gomarkdoc/blob/master/renderer.go#L160>)
<a name="Renderer.Package"></a>
### func \(\*Renderer\) [Package](<https://github.com/princjef/gomarkdoc/blob/master/renderer.go#L163>)

```go
func (out *Renderer) Package(pkg *lang.Package) (string, error)
```

Package renders a package's documentation to a string. You can change the rendering of the package by overriding the "package" template or one of the templates it references.

### func \(\*Renderer\) [Type](<https://github.com/princjef/gomarkdoc/blob/master/renderer.go#L174>)
<a name="Renderer.Type"></a>
### func \(\*Renderer\) [Type](<https://github.com/princjef/gomarkdoc/blob/master/renderer.go#L177>)

```go
func (out *Renderer) Type(typ *lang.Type) (string, error)
```

Type renders a type's documentation to a string. You can change the rendering of the type by overriding the "type" template or one of the templates it references.

<a name="RendererOption"></a>
## type [RendererOption](<https://github.com/princjef/gomarkdoc/blob/master/renderer.go#L23>)

RendererOption configures the renderer's behavior.
Expand All @@ -307,15 +315,17 @@ RendererOption configures the renderer's behavior.
type RendererOption func(renderer *Renderer) error
```

### func [WithFormat](<https://github.com/princjef/gomarkdoc/blob/master/renderer.go#L143>)
<a name="WithFormat"></a>
### func [WithFormat](<https://github.com/princjef/gomarkdoc/blob/master/renderer.go#L146>)

```go
func WithFormat(format format.Format) RendererOption
```

WithFormat changes the renderer to use the format provided instead of the default format.

### func [WithTemplateOverride](<https://github.com/princjef/gomarkdoc/blob/master/renderer.go#L129>)
<a name="WithTemplateOverride"></a>
### func [WithTemplateOverride](<https://github.com/princjef/gomarkdoc/blob/master/renderer.go#L132>)

```go
func WithTemplateOverride(name, tmpl string) RendererOption
Expand Down
5 changes: 3 additions & 2 deletions cmd/gomarkdoc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ import "github.com/princjef/gomarkdoc/cmd/gomarkdoc"

Package gomarkdoc provides a command line interface for writing golang documentation in markdown format.

See https://github.com/princjef/gomarkdoc for full documentation of this tool.
See https://github.com/princjef/gomarkdoc[https://github.com/princjef/gomarkdoc](<https://github.com/princjef/gomarkdoc>) for full documentation of this tool.

## Index

- [type PackageSpec](<#type-packagespec>)
- [type PackageSpec](<#PackageSpec>)


<a name="PackageSpec"></a>
## type [PackageSpec](<https://github.com/princjef/gomarkdoc/blob/master/cmd/gomarkdoc/command.go#L30-L44>)

PackageSpec defines the data available to the \-\-output option's template. Information is recomputed for each package generated.
Expand Down
Loading

0 comments on commit cc78abb

Please sign in to comment.