apidoc

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2024 License: GPL-3.0 Imports: 13 Imported by: 0

README

Api Doc Open in Gitpod

tests Go Report Card PkgGoDev

API Documentation Builder

License

This project is licensed under the GNU General Public License version 3 (GPL-3.0). You can find a copy of the license at https://www.gnu.org/licenses/gpl-3.0.en.html

For commercial use, please use my contact page to obtain a commercial license.

Introduction

The Api Doc project helps to build and serve documentation using Go.

No external dependencies are required (npm, yarn, etc).

Features

  • Seamless Integration: Generate documentation directly from your Go code for accuracy and efficiency.
  • Reduced Overhead: Minimize the need to maintain separate applications or specification files.
  • Customization and Flexibility: Tailor your documentation to your specific needs and preferences.
  • Performance and Efficiency: Enjoy faster build times and reduced overhead compared to OpenAPI.
  • Simplified Tooling and Reduced Dependencies: Leverage the Go ecosystem for efficient development.
  • Steep Learning Curve: Benefit from a shallower learning curve if you're already proficient in Go.
  • Declarative Approach: Define your API's structure and content using Go code, making it more intuitive and easier to maintain.
  • Extensible: Easily add custom extensions or features to your documentation.

Supported Themes

Light Themes
  • default

apidoc-theme-default

  • cerulean

apidoc-theme-cerulean

  • cosmo

apidoc-theme-cosmo

  • flatly

apidoc-theme-flatly

  • journal

apidoc-theme-journal

  • litera

apidoc-theme-litera

  • lux

apidoc-theme-lux

  • materia

apidoc-theme-materia

  • minty

apidoc-theme-minty

  • morph

apidoc-theme-morph

  • pulse

apidoc-theme-pulse

  • quartz

apidoc-theme-quartz

  • sandstone

apidoc-theme-sandstone

  • simplex

apidoc-theme-simplex

  • sketchy

apidoc-theme-sketchy

  • spacelab

apidoc-theme-spacelab

  • united

apidoc-theme-united

  • yeti

apidoc-theme-yeti

  • zephyr

apidoc-theme-zephyr

Dark Themes
  • cyborg

apidoc-theme-cyborg

  • darkly

apidoc-theme-darkly

  • slate

apidoc-theme-slate

  • solar

apidoc-theme-solar

  • superhero

apidoc-theme-superhero

  • vapor

apidoc-theme-vapor

Credits

Documentation

Index

Constants

View Source
const BLOCK_TYPE_ENDPOINT = "endpoint"
View Source
const BLOCK_TYPE_EXAMPLE = "example"
View Source
const BLOCK_TYPE_GROUP = "group"

Block Types

View Source
const BLOCK_TYPE_PARAMETER = "parameter"
View Source
const BLOCK_TYPE_RESPONSE = "response"
View Source
const BLOCK_TYPE_SECTION = "section"
View Source
const CONTENT_TYPE_FORM = "application/x-www-form-urlencoded"
View Source
const CONTENT_TYPE_JSON = "application/json"

Content types

View Source
const CONTENT_TYPE_MULTIPART = "multipart/form-data"
View Source
const CONTENT_TYPE_TEXT = "text/plain"
View Source
const PARAMETER_LOCATION_BODY = "body"

PARAMETER_LOCATION_BODY represents a parameter located in the HTTP request body as a JSON payload or other structured data (e.g. {"name": "John"}).

View Source
const PARAMETER_LOCATION_COOKIE = "cookie"

PARAMETER_LOCATION_COOKIE represents a parameter located in the HTTP request cookie (e.g. token).

View Source
const PARAMETER_LOCATION_FORM = "form"

PARAMETER_LOCATION_FORM represents a parameter located in the HTTP request body as form data (e.g. name=John).

View Source
const PARAMETER_LOCATION_HEADER = "header"

PARAMETER_LOCATION_HEADER represents a parameter located in the HTTP request header (e.g. Authorization).

View Source
const PARAMETER_LOCATION_PATH = "path"

PARAMETER_LOCATION_PATH represents a parameter located in the URL path (e.g. /users/:id).

View Source
const PARAMETER_LOCATION_QUERY = "query"

PARAMETER_LOCATION_QUERY represents a parameter located in the URL query string (e.g. ?id=1).

View Source
const THEME_CERULEAN = "cerulean"
View Source
const THEME_COSMO = "cosmo"
View Source
const THEME_CYBORG = "cyborg"

Dark themes

View Source
const THEME_DARKLY = "darkly"
View Source
const THEME_DEFAULT = "bootstrap"

Light themes

View Source
const THEME_FLATLY = "flatly"
View Source
const THEME_JOURNAL = "journal"
View Source
const THEME_LITERA = "litera"
View Source
const THEME_LUMEN = "lumen"
View Source
const THEME_LUX = "lux"
View Source
const THEME_MATERIA = "materia"
View Source
const THEME_MINTY = "minty"
View Source
const THEME_MORPH = "morph"
View Source
const THEME_PULSE = "pulse"
View Source
const THEME_QUARTZ = "quartz"
View Source
const THEME_SANDSTONE = "sandstone"
View Source
const THEME_SIMPLEX = "simplex"
View Source
const THEME_SKETCHY = "sketchy"
View Source
const THEME_SLATE = "slate"
View Source
const THEME_SOLAR = "solar"
View Source
const THEME_SPACELAB = "spacelab"
View Source
const THEME_SUPERHERO = "superhero"
View Source
const THEME_UNITED = "united"
View Source
const THEME_VAPOR = "vapor"
View Source
const THEME_YETI = "yeti"
View Source
const THEME_ZEPHYR = "zephyr"

Variables

This section is empty.

Functions

func NewWebController

func NewWebController(documentation Documentation) *webController

NewwebController creates a new web controller

Types

type BlockInterface

type BlockInterface interface {
	// GetType returns the type of the block
	GetType() string

	// GetTitle returns the title of the block
	GetTitle() string

	// GetContent returns the content of the block
	GetContent() string
}

type Documentation

type Documentation struct {
	// contains filtered or unexported fields
}

func NewDocumentation

func NewDocumentation() *Documentation

func (*Documentation) AddBlock

func (doc *Documentation) AddBlock(block BlockInterface) *Documentation

func (*Documentation) GetBlocks

func (doc *Documentation) GetBlocks() []BlockInterface

func (*Documentation) GetDescription

func (doc *Documentation) GetDescription() string

func (*Documentation) GetHandlerURL

func (doc *Documentation) GetHandlerURL() string

GetHandlerURL returns the URL to the handler serving the documentation

func (*Documentation) GetHomeURL

func (doc *Documentation) GetHomeURL() string
func (doc *Documentation) GetLogo() string

func (*Documentation) GetTheme

func (doc *Documentation) GetTheme() string

func (*Documentation) GetThemesDark

func (doc *Documentation) GetThemesDark() []struct {
	Key  string
	Name string
}

func (*Documentation) GetThemesLight

func (doc *Documentation) GetThemesLight() []struct {
	Key  string
	Name string
}

func (*Documentation) GetTitle

func (doc *Documentation) GetTitle() string

func (*Documentation) IsThemeDark

func (doc *Documentation) IsThemeDark(theme string) bool

func (*Documentation) IsThemeLight

func (doc *Documentation) IsThemeLight(theme string) bool

func (*Documentation) SetBlocks

func (doc *Documentation) SetBlocks(blocks []BlockInterface) *Documentation

func (*Documentation) SetDescription

func (doc *Documentation) SetDescription(description string) *Documentation

func (*Documentation) SetHandlerURL

func (doc *Documentation) SetHandlerURL(handlerURL string) *Documentation

SetHandlerURL sets the URL to the handler serving the documentation

func (*Documentation) SetHomeURL

func (doc *Documentation) SetHomeURL(homeURL string) *Documentation
func (doc *Documentation) SetLogo(logo string) *Documentation

func (*Documentation) SetTheme

func (doc *Documentation) SetTheme(theme string) *Documentation

func (*Documentation) SetThemesDark

func (doc *Documentation) SetThemesDark(themesDark []struct {
	Key  string
	Name string
}) *Documentation

func (*Documentation) SetThemesLight

func (doc *Documentation) SetThemesLight(themesLight []struct {
	Key  string
	Name string
}) *Documentation

func (*Documentation) SetTitle

func (doc *Documentation) SetTitle(title string) *Documentation

type Endpoint

type Endpoint struct {
	// contains filtered or unexported fields
}

Endpoint represents an endpoint block it is used to describe an API endpoint to the documentation

func NewEndpoint

func NewEndpoint() *Endpoint

func (*Endpoint) AddParameter

func (block *Endpoint) AddParameter(Parameter Parameter) *Endpoint

func (*Endpoint) AddResponse

func (block *Endpoint) AddResponse(response Response) *Endpoint

func (*Endpoint) GetContent

func (block *Endpoint) GetContent() string

func (*Endpoint) GetDescription

func (block *Endpoint) GetDescription() string

GetDescription is an alias for GetContent

func (*Endpoint) GetMethod

func (block *Endpoint) GetMethod() string

func (*Endpoint) GetParameters

func (block *Endpoint) GetParameters() []Parameter

func (*Endpoint) GetPath

func (block *Endpoint) GetPath() string

func (*Endpoint) GetResponses

func (block *Endpoint) GetResponses() []Response

func (*Endpoint) GetTitle

func (block *Endpoint) GetTitle() string

func (*Endpoint) GetType

func (block *Endpoint) GetType() string

func (*Endpoint) SetContent

func (block *Endpoint) SetContent(content string) *Endpoint

func (*Endpoint) SetDescription

func (block *Endpoint) SetDescription(description string) *Endpoint

SetDescription is an alias for SetContent

func (*Endpoint) SetMethod

func (block *Endpoint) SetMethod(method string) *Endpoint

func (*Endpoint) SetParameters

func (block *Endpoint) SetParameters(Parameters []Parameter) *Endpoint

func (*Endpoint) SetPath

func (block *Endpoint) SetPath(path string) *Endpoint

func (*Endpoint) SetResponses

func (block *Endpoint) SetResponses(responses []Response) *Endpoint

func (*Endpoint) SetTitle

func (block *Endpoint) SetTitle(title string) *Endpoint

func (*Endpoint) SetType

func (block *Endpoint) SetType(blockType string) *baseBlock

type Example

type Example struct {
	// contains filtered or unexported fields
}

Example represents an example block with a source code example it is used to add an example section to an endpoint

func NewExample

func NewExample() *Example

func (*Example) GetContent

func (block *Example) GetContent() string

func (*Example) GetDescription

func (block *Example) GetDescription() string

GetDescription is an alias for GetContent

func (*Example) GetSourceCode

func (block *Example) GetSourceCode() string

func (*Example) GetSourceLanguage

func (block *Example) GetSourceLanguage() string

func (*Example) GetTitle

func (block *Example) GetTitle() string

func (*Example) GetType

func (block *Example) GetType() string

func (*Example) SetContent

func (block *Example) SetContent(content string) *Example

func (*Example) SetDescription

func (block *Example) SetDescription(description string) *Example

SetDescription is an alias for SetContent

func (*Example) SetSourceCode

func (block *Example) SetSourceCode(sourceCode string) *Example

func (*Example) SetSourceLanguage

func (block *Example) SetSourceLanguage(sourceLanguage string) *Example

func (*Example) SetTitle

func (block *Example) SetTitle(title string) *Example

func (*Example) SetType

func (block *Example) SetType(blockType string) *baseBlock

type Group

type Group struct {
	// contains filtered or unexported fields
}

Group represents a block with a title and content it is used to group blocks of similar functionality

func NewGroup

func NewGroup() *Group

func (*Group) AddBlock

func (block *Group) AddBlock(child BlockInterface) *Group

func (*Group) GetBlocks

func (block *Group) GetBlocks() []BlockInterface

func (*Group) GetContent

func (block *Group) GetContent() string

func (*Group) GetDescription

func (block *Group) GetDescription() string

GetDescription is an alias for GetContent

func (*Group) GetTitle

func (block *Group) GetTitle() string

func (*Group) GetType

func (block *Group) GetType() string

func (*Group) SetBlocks

func (block *Group) SetBlocks(blocks []BlockInterface) *Group

func (*Group) SetContent

func (block *Group) SetContent(content string) *Group

func (*Group) SetDescription

func (block *Group) SetDescription(content string) *Group

SetDescription is an alias for SetContent

func (*Group) SetTitle

func (block *Group) SetTitle(title string) *Group

func (*Group) SetType

func (block *Group) SetType(blockType string) *baseBlock

type Parameter

type Parameter struct {
	// contains filtered or unexported fields
}

func NewParameter

func NewParameter() *Parameter

func (*Parameter) GetContent

func (block *Parameter) GetContent() string

func (*Parameter) GetDescription

func (block *Parameter) GetDescription() string

GetDescription is an alias for GetContent

func (*Parameter) GetLocation

func (block *Parameter) GetLocation() string

func (*Parameter) GetName

func (block *Parameter) GetName() string

func (*Parameter) GetRequired

func (block *Parameter) GetRequired() bool

func (*Parameter) GetTitle

func (block *Parameter) GetTitle() string

func (*Parameter) GetType

func (block *Parameter) GetType() string

func (*Parameter) SetContent

func (block *Parameter) SetContent(content string) *Parameter

func (*Parameter) SetDescription

func (block *Parameter) SetDescription(content string) *Parameter

SetDescription is an alias for SetContent

func (*Parameter) SetLocation

func (block *Parameter) SetLocation(location string) *Parameter

func (*Parameter) SetName

func (block *Parameter) SetName(name string) *Parameter

func (*Parameter) SetRequired

func (block *Parameter) SetRequired(required bool) *Parameter

func (*Parameter) SetTitle

func (block *Parameter) SetTitle(title string) *Parameter

func (*Parameter) SetType

func (block *Parameter) SetType(dataType string) *Parameter

type Response

type Response struct {
	// contains filtered or unexported fields
}

Response represents a block with a title and content it is used to add a response section to an endpoint

func NewResponse

func NewResponse() *Response

func (*Response) GetContent

func (block *Response) GetContent() string

func (*Response) GetContentType

func (block *Response) GetContentType() string

func (*Response) GetDescription

func (block *Response) GetDescription() string

GetDescription is an alias for GetContent

func (*Response) GetExample

func (block *Response) GetExample() Example

func (*Response) GetStatusCode

func (block *Response) GetStatusCode() string

func (*Response) GetTitle

func (block *Response) GetTitle() string

func (*Response) GetType

func (block *Response) GetType() string

func (*Response) SetContent

func (block *Response) SetContent(content string) *Response

func (*Response) SetContentType

func (block *Response) SetContentType(contentType string) *Response

func (*Response) SetDescription

func (block *Response) SetDescription(description string) *Response

SetDescription is an alias for SetContent

func (*Response) SetExample

func (block *Response) SetExample(example Example) *Response

func (*Response) SetStatusCode

func (block *Response) SetStatusCode(statusCode string) *Response

func (*Response) SetTitle

func (block *Response) SetTitle(title string) *Response

func (*Response) SetType

func (block *Response) SetType(blockType string) *baseBlock

type Section

type Section struct {
	// contains filtered or unexported fields
}

Section represents a section block with a title and content it is used to add an information section to the documentation

func NewSection

func NewSection() *Section

func (*Section) GetContent

func (block *Section) GetContent() string

func (*Section) GetDescription

func (block *Section) GetDescription() string

GetDescription is an alias for GetContent

func (*Section) GetTitle

func (block *Section) GetTitle() string

func (*Section) GetType

func (block *Section) GetType() string

func (*Section) SetContent

func (block *Section) SetContent(content string) *Section

func (*Section) SetDescription

func (block *Section) SetDescription(description string) *Section

SetDescription is an alias for SetContent

func (*Section) SetTitle

func (block *Section) SetTitle(title string) *Section

func (*Section) SetType

func (block *Section) SetType(blockType string) *baseBlock

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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