hechodoc

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2022 License: MIT Imports: 15 Imported by: 0

README

Conventions:

  • You must create openapi go file initially. (e.g., openapi_docs.go)

Notes:

  • raw route name is the raw route name which we set on route definition in our source code. e.g., hi::mehran
  • route name in the source code is camelcased value of the raw route name e.g., hiMehran.

How to generate docs?

  • Install swagger
  • Place a package named something like doc.
  • In the doc package create a file named something like openapi_docs.go. This is your openapi comments file, so all of your documentation should be in this file.
  • In the doc package create another package named gen
  • In your main file import doc package as blank. (e.g., _ "github.com/kamva/hexa-echo/examples/docexample/doc")
  • Now in you source code create two commands: extract,trim.
  • In order run extract template and trim template commands. sample in the examples package´.

FAQ:

  • How should I install swagger command? simply install it as go package:
GO111MODULE=off go get -u github.com/go-swagger/go-swagger/cmd/swagger

Documentation

Index

Constants

View Source
const (
	BeginRoutePrefix = "// route:begin: "
	EndRoutePrefix   = "// route:end: "
)

Variables

View Source
var DefaultRouteNameConverter = NewDividerNameConverter("::", 0)

DefaultRouteNameConverter is the default route name Converter.

View Source
var DefaultSingleRouteTemplatePath = path.Join(gutil.SourcePath(), "default_template.tpl")

Functions

func OpenApiPathFromEchoPath

func OpenApiPathFromEchoPath(path string) string

OpenApiPathFromEchoPath convert echo path to openapi path. e.g, a/:id/:code => a/{id}/{code}

func SortEchoRoutesByName

func SortEchoRoutesByName(routes []*echo.Route) []*echo.Route

Types

type Extractor

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

func NewExtractor

func NewExtractor(o ExtractorOptions) *Extractor

func (*Extractor) Extract

func (e *Extractor) Extract() error

type ExtractorOptions

type ExtractorOptions struct {
	Echo                    *echo.Echo
	ExtractDestinationPath  string // Destination path of extract filePath
	SingleRouteTemplatePath string
	Converter               RouteNameConverter
}

type PathParam

type PathParam struct {
	Name         string
	ExportedName string
}

func PathParams

func PathParams(p string) []PathParam

type Route

type Route struct {
	BeginRouteVal string
	EndRouteVal   string
	Name          string
	RawName       string
	Method        string
	Path          string
	PathParams    []PathParam
	TagsString    string
	ParamsId      string
	SuccessRespId string
}

type RouteNameConverter

type RouteNameConverter interface {
	Tags(name string) []string // give tags from route name
	CamelCase(name string) string
}

func NewDividerNameConverter

func NewDividerNameConverter(div string, maxTag int) RouteNameConverter

type Trimmer

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

func NewTrimmer

func NewTrimmer(o TrimmerOptions) *Trimmer

func (*Trimmer) Trim

func (t *Trimmer) Trim() error

type TrimmerOptions

type TrimmerOptions struct {
	Echo                   *echo.Echo
	ExtractDestinationPath string
}

Jump to

Keyboard shortcuts

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