docs

package module
v0.0.0-...-659c3a4 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2021 License: MIT Imports: 14 Imported by: 1

README

Documentation

Overview

Package docs can be used to gather go-ipfs commands and automatically generate documentation or tests.

Index

Constants

View Source
const APIPrefix = "/api/v0"
View Source
const IndentLevel = 4

How much to indent when generating the response schemas

View Source
const MaxIndent = 20

Failsafe when traversing objects containing objects of the same type

Variables

View Source
var IgnoreEndpoints = map[string]bool{}

A map of single endpoints to be skipped (subcommands are processed though).

View Source
var JsondocGlossary = jsondoc.NewGlossary().
	WithSchema(new(cid.Cid), jsondoc.Object{"/": "<cid-string>"}).
	WithName(new(multiaddr.Multiaddr), "multiaddr-string").
	WithName(new(peer.ID), "peer-id").
	WithSchema(new(peer.AddrInfo),
		jsondoc.Object{"ID": "peer-id", "Addrs": []string{"<multiaddr-string>"}})

Functions

func GenerateDocs

func GenerateDocs(api []*Endpoint, formatter Formatter) string

GenerateDocs uses a formatter to generate documentation for every endpoint

func IPFSVersion

func IPFSVersion() string

Types

type Argument

type Argument struct {
	Endpoint    string
	Name        string
	Description string
	Type        string
	Required    bool
	Default     string
}

Argument defines an IPFS RPC API endpoint argument.

type Endpoint

type Endpoint struct {
	Name        string
	Arguments   []*Argument
	Options     []*Argument
	Description string
	Response    string
	Group       string
}

Endpoint defines an IPFS RPC API endpoint.

func AllEndpoints

func AllEndpoints() []*Endpoint

AllEndpoints gathers all the endpoints from go-ipfs.

func Endpoints

func Endpoints(name string, cmd *cmds.Command) (endpoints []*Endpoint)

Endpoints receives a name and a go-ipfs command and returns the endpoints it defines] (sorted). It does this by recursively gathering endpoints defined by subcommands. Thus, calling it with the core command Root generates all the endpoints.

type Formatter

type Formatter interface {
	GenerateIntro() string
	GenerateIndex(endp []*Endpoint) string
	GenerateEndpointBlock(endp *Endpoint) string
	GenerateArgumentsBlock(args []*Argument, opts []*Argument) string
	GenerateBodyBlock(args []*Argument) string
	GenerateResponseBlock(response string) string
	GenerateExampleBlock(endp *Endpoint) string
}

Formatter allows to implement generation of docs in different formats.

type MarkdownFormatter

type MarkdownFormatter struct{}

MarkdownFormatter implements a markdown doc generator. It is used to generate the IPFS website API reference at https://github.com/ipfs/website/blob/master/content/pages/docs/api.md

func (*MarkdownFormatter) GenerateArgumentsBlock

func (md *MarkdownFormatter) GenerateArgumentsBlock(args []*Argument, opts []*Argument) string

func (*MarkdownFormatter) GenerateBodyBlock

func (md *MarkdownFormatter) GenerateBodyBlock(args []*Argument) string

func (*MarkdownFormatter) GenerateEndpointBlock

func (md *MarkdownFormatter) GenerateEndpointBlock(endp *Endpoint) string

func (*MarkdownFormatter) GenerateExampleBlock

func (md *MarkdownFormatter) GenerateExampleBlock(endp *Endpoint) string

func (*MarkdownFormatter) GenerateIndex

func (md *MarkdownFormatter) GenerateIndex(endps []*Endpoint) string

func (*MarkdownFormatter) GenerateIntro

func (md *MarkdownFormatter) GenerateIntro() string

func (*MarkdownFormatter) GenerateResponseBlock

func (md *MarkdownFormatter) GenerateResponseBlock(response string) string

Directories

Path Synopsis
This is an utility to generate documentation from go-ipfs commands
This is an utility to generate documentation from go-ipfs commands

Jump to

Keyboard shortcuts

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