Documentation ¶
Overview ¶
diagram-creation.go: all the methods attached to the generator object to be used in templating
generator.go: struct for converting sysl modules to documentation (Generator)
server.go: implements http handler interface so that Generator struct can be used directly as a handler
markdown-template.go: the markdown template used to template the sysl module
markdown-template.go: the markdown template used to template the sysl module
util.go: misc functions to convert/send http requests/sort maps
Index ¶
- Constants
- func Attribute(a Attr, query string) string
- func BuildSpecURL(filePath string, version string) string
- func CreateFileName(dir string, elems ...string) (string, string)
- func CreateSequenceDiagram(m *sysl.Module, call string) (string, error)
- func FieldType(t *sysl.Type) string
- func Fields(t *sysl.Type) map[string]*sysl.Type
- func Filter(vs []string, f func(string) bool) []string
- func GetAppNameString(a Namer) string
- func GetAppPackageName(a Namer) (string, string)
- func GetAppTypeName(param Typer) (appName string, typeName string)
- func GetImportPathAndVersion(retr gop.Retriever, app *sysl.Application) (importPath string, version string, err error)
- func GetPackageName(m *sysl.Module, a Namer) string
- func IsOpenAPIFile(filePath string) bool
- func JoinAppNameString(an *sysl.AppName) string
- func Last(i interface{}, ind int) bool
- func ModuleNamespace(m *sysl.Module) string
- func ModulePackageName(m *sysl.Module) string
- func NewTypeRef(appName, typeName string) *sysl.Type
- func PlantUMLURL(plantumlService, contents string) string
- func Remove(s string, old ...string) string
- func SanitiseOutputName(s string) string
- func ServiceMetadata(a Attr) string
- func SimpleName(app *sysl.Application) string
- func SortedKeys(m interface{}) []string
- func TernaryOperator(condition bool, i ...interface{}) interface{}
- func UnmarshallJson(b []byte, m *sysl.Module) error
- type Attr
- type Generator
- func (p *Generator) AutomaticTemplates(fs afero.Fs, fileNames ...string) *Generator
- func (p *Generator) CreateMarkdown(t *template.Template, outputFileName string, i interface{}) error
- func (p *Generator) CreateRedoc(app *sysl.Application, appName string) string
- func (p *Generator) DataModelAliasMermaid(app *sysl.Application, param Param) string
- func (p *Generator) DataModelAliasPlantuml(appName, typeName, typeAlias string, t *sysl.Type, recursive bool) string
- func (p *Generator) DataModelAliasTable(app *sysl.Application, param Param) string
- func (p *Generator) DataModelAppMermaid(app *sysl.Application) string
- func (p *Generator) DataModelAppPlantuml(app *sysl.Application) string
- func (p *Generator) DataModelMermaid(appName, typeName string) string
- func (p *Generator) DataModelParamPlantuml(app *sysl.Application, param Param) string
- func (p *Generator) DataModelPlantuml(appName, typeName string, t *sysl.Type, recursive bool) string
- func (p *Generator) DataModelReturnMermaid(appName string, stmnt *sysl.Statement, endpoint *sysl.Endpoint) string
- func (p *Generator) DataModelReturnPlantuml(appName string, stmnt *sysl.Statement, endpoint *sysl.Endpoint) string
- func (p *Generator) DataModelReturnTable(appName string, stmt *sysl.Statement, endpoint *sysl.Endpoint) string
- func (p *Generator) DataModelTable(appName, typeName, aliasName string) string
- func (p *Generator) ExtractReturnInfo(appname string, stmnt *sysl.Statement, endpoint *sysl.Endpoint) (appName string, typeName string, typeref *sysl.Type, getRecursive bool)
- func (p *Generator) ExtractTypeInfo(app *sysl.Application, param Param) (appName, typeName, aliasTypeName string, getRecursive bool)
- func (p *Generator) GetFuncMap() template.FuncMap
- func (p *Generator) GetParamType(app *sysl.Application, param *sysl.Param) *sysl.Type
- func (p *Generator) GetReturnType(endpoint *sysl.Endpoint, stmnt *sysl.Statement) *sysl.Type
- func (p *Generator) IntegrationMermaid(m *sysl.Module, title string, EPA bool) string
- func (p *Generator) IntegrationPlantuml(m *sysl.Module, title string, EPA bool) string
- func (p *Generator) MacroPackages(module *sysl.Module) []string
- func (p *Generator) ModuleAsMacroPackage(m *sysl.Module) map[string]*sysl.Module
- func (p *Generator) ModuleAsPackages(m *sysl.Module) map[string]*sysl.Module
- func (p *Generator) Packages(m *sysl.Module) []string
- func (p *Generator) Run()
- func (p *Generator) SequenceMermaid(appName string, endpoint *sysl.Endpoint) string
- func (p *Generator) SequencePlantuml(appName string, endpoint *sysl.Endpoint) string
- func (p *Generator) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (p *Generator) ServerSettings(disableCSS, liveReload, imageTags bool) *Generator
- func (p *Generator) SetOptions(disableCss bool, readmeName, ImageDest string) *Generator
- func (p *Generator) SourcePath(a SourceCoder) string
- func (p *Generator) Update(m *sysl.Module, errs ...error) *Generator
- func (p *Generator) WithRemoteTemplateString(remoteResources ...string) *Generator
- func (p *Generator) WithRetriever(retr gop.Retriever) *Generator
- func (p *Generator) WithTemplateFs(fs afero.Fs, fileNames ...string) *Generator
- func (p *Generator) WithTemplateString(tmpls ...string) *Generator
- type Namer
- type Param
- type Redoc
- type SourceCoder
- type Typer
Constants ¶
const MacroPackageProject = `` /* 487-byte string literal not displayed */
const MacroPackageProjectMermaid = `` /* 602-byte string literal not displayed */
const NewPackageTemplate = `` /* 5899-byte string literal not displayed */
const NewPackageTemplateMermaid = `` /* 5514-byte string literal not displayed */
const ProjectTemplate = `` /* 486-byte string literal not displayed */
const ProjectTemplateMermaid = `` /* 600-byte string literal not displayed */
const RedocPage = `` /* 647-byte string literal not displayed */
Variables ¶
This section is empty.
Functions ¶
func BuildSpecURL ¶ added in v1.4.50
BuildSpecURL takes a filepath and version and builds a URL to the cached spec file It also trims . prefixes and adds a / so that the URL is relative
func CreateFileName ¶ added in v1.3.0
CreateFileName returns the absolute and relative filepaths
func CreateSequenceDiagram ¶
CreateSequenceDiagram creates an sequence diagram and returns the sequence diagram string and any errors
func GetAppNameString ¶ added in v1.4.193
GetAppNameString returns an app's name as a string, with the namespace joined on "::".
func GetAppPackageName ¶
GetAppPackageName returns the package and app name of any sysl application
func GetAppTypeName ¶ added in v1.3.0
GetAppTypeName takes a Sysl Type and returns the appName and typeName of a param If the type is a primitive, the appName returned is "primitive"
func GetImportPathAndVersion ¶ added in v1.4.186
func GetImportPathAndVersion(retr gop.Retriever, app *sysl.Application) (importPath string, version string, err error)
GetImportPathAndVersion takes a Sysl Application and returns an import and version string The import path is of format github.com/org/repo/myfile.yaml it CAN contain version tags e.g github.com/org/repo/myfile.yaml@develop or github.com/org/repo/myfile.yaml@v1.1.0 The version string is of format version-12digitCommitSHA e.g v0.0.0-c63b9e92813a
func IsOpenAPIFile ¶ added in v1.4.50
func JoinAppNameString ¶ added in v1.4.193
JoinAppNameString transforms an AppName to a string, with the namespace joined on "::".
func ModuleNamespace ¶ added in v1.4.203
ModuleNamespace returns the namespace associated with the module (if the module is grouped by a namespace).
func ModulePackageName ¶ added in v1.2.31
ModulePackageName returns the package name associated with the module (that of one of its apps).
func NewTypeRef ¶ added in v1.2.30
NewTypeRef returns a type reference, needed to correctly generate data model diagrams
func PlantUMLURL ¶ added in v1.2.31
PlantUMLURL returns a PlantUML url
func SanitiseOutputName ¶ added in v1.2.31
SanitiseOutputName removes characters so that the string can be used as a hyperlink.
func ServiceMetadata ¶ added in v1.4.103
func SimpleName ¶ added in v1.4.203
func SimpleName(app *sysl.Application) string
SimpleName returns the last part of an app name.
func SortedKeys ¶ added in v1.3.0
func SortedKeys(m interface{}) []string
func TernaryOperator ¶ added in v1.2.31
func TernaryOperator(condition bool, i ...interface{}) interface{}
TernaryOperator returns the first element if bool is true and the second element is false
Types ¶
type Generator ¶ added in v1.2.31
type Generator struct { RootModule *sysl.Module FilesToCreate map[string]string MermaidFilesToCreate map[string]string RedocFilesToCreate map[string]string GeneratedFiles map[string][]byte SourceFileName string ProjectTitle string ImageDest string // Output all images into this folder is set Format string // "html" or "markdown" or "" if custom OutputFileName string PlantumlService string Templates []*template.Template Redoc *template.Template StartTemplateIndex int FilterPackage []string // Filter these regex terms out of packagenames Retriever gop.Retriever CustomTemplate bool LiveReload bool // Add live reload javascript to html DisableCss bool // used for rendering raw markdown Log *logrus.Logger Fs afero.Fs // All of these are used in markdown generation Module *sysl.Module CurrentDir string TempDir string Title string OutputDir string Links map[string]string Server bool Mapper *syslwrapper.AppMapper BasePath string // for using on another endpoint that isn't '/' // contains filtered or unexported fields }
Generator is the contextual object that is used in the markdown generation
func NewProject ¶
func NewProject( titleAndFileName, plantumlService, outputType string, logger *logrus.Logger, module *sysl.Module, fs afero.Fs, outputDir string) *Generator
NewProject generates a Generator object, fs and outputDir are optional if being used for a web server.
func NewProjectFromJson ¶ added in v1.4.181
func NewProjectFromJson( titleAndFileName, plantumlService, outputType string, logger *logrus.Logger, module []byte, fs afero.Fs, outputDir string) *Generator
NewProjectFromJson generates a generator object with a json byte input (of a sysl module) instead of a sysl module
func (*Generator) AutomaticTemplates ¶ added in v1.4.196
func (*Generator) CreateMarkdown ¶ added in v1.2.31
func (p *Generator) CreateMarkdown(t *template.Template, outputFileName string, i interface{}) error
CreateMarkdown is a wrapper function that also converts output markdown to html if in server mode
func (*Generator) CreateRedoc ¶ added in v1.4.50
func (p *Generator) CreateRedoc(app *sysl.Application, appName string) string
CreateRedoc registers a file that needs to be created when either: - The @redoc-spec attribute has been set - The source context has an extension suggesting it is an OpenAPI file
func (*Generator) DataModelAliasMermaid ¶ added in v1.4.196
func (p *Generator) DataModelAliasMermaid(app *sysl.Application, param Param) string
func (*Generator) DataModelAliasPlantuml ¶ added in v1.4.196
func (p *Generator) DataModelAliasPlantuml(appName, typeName, typeAlias string, t *sysl.Type, recursive bool) string
DataModelAliasPlantuml generates a plantuml url for a alias data model
func (*Generator) DataModelAliasTable ¶ added in v1.4.199
func (p *Generator) DataModelAliasTable(app *sysl.Application, param Param) string
DataModelAliasTable prints out a markdown table for a given application and parameter
func (*Generator) DataModelAppMermaid ¶ added in v1.4.196
func (p *Generator) DataModelAppMermaid(app *sysl.Application) string
func (*Generator) DataModelAppPlantuml ¶ added in v1.4.196
func (p *Generator) DataModelAppPlantuml(app *sysl.Application) string
DataModelAppPlantuml generates a data model for all of the types in app and returns a plantuml url
func (*Generator) DataModelMermaid ¶ added in v1.4.196
func (*Generator) DataModelParamPlantuml ¶ added in v1.4.196
func (p *Generator) DataModelParamPlantuml(app *sysl.Application, param Param) string
DataModelParamPlantuml creates a parameter data model and returns a plantuml url
func (*Generator) DataModelPlantuml ¶ added in v1.4.196
func (*Generator) DataModelReturnMermaid ¶ added in v1.4.196
func (*Generator) DataModelReturnPlantuml ¶ added in v1.4.196
func (p *Generator) DataModelReturnPlantuml(appName string, stmnt *sysl.Statement, endpoint *sysl.Endpoint) string
DataModelReturnPlantuml returns a return datamodel as a plantuml url
func (*Generator) DataModelReturnTable ¶ added in v1.4.199
func (p *Generator) DataModelReturnTable(appName string, stmt *sysl.Statement, endpoint *sysl.Endpoint) string
DataModelReturnTable prints out a markdown table for a given statement and endpoint
func (*Generator) DataModelTable ¶ added in v1.4.199
DataModelTable prints out a markdown table which describes a type
func (*Generator) ExtractReturnInfo ¶ added in v1.4.196
func (*Generator) ExtractTypeInfo ¶ added in v1.4.196
func (*Generator) GetFuncMap ¶ added in v1.2.31
GetFuncMap returns the funcs that are used in diagram generation.
func (*Generator) GetParamType ¶ added in v1.2.31
GetReturnType converts an application and a param into a type, useful for getting attributes.
func (*Generator) GetReturnType ¶ added in v1.2.31
GetReturnType converts an endpoint and a statement into a type, useful for getting attributes.
func (*Generator) IntegrationMermaid ¶ added in v1.4.196
func (*Generator) IntegrationPlantuml ¶ added in v1.4.196
IntegrationPlantuml creates an integration diagram and returns the plantuml string
func (*Generator) MacroPackages ¶ added in v1.4.17
MacroPackages executes the markdown for a MacroPackage and returns a slice of the rows
func (*Generator) ModuleAsMacroPackage ¶ added in v1.3.0
func (*Generator) ModuleAsPackages ¶ added in v1.3.0
ModuleAsPackages returns a map of [packagename]*sysl.Module
func (*Generator) Packages ¶ added in v1.4.17
Packages executes the markdown for a package and returns a slice of the rows
func (*Generator) Run ¶ added in v1.2.31
func (p *Generator) Run()
Run Executes a project and generates markdown and diagrams to a given filesystem.
func (*Generator) SequenceMermaid ¶ added in v1.4.196
func (*Generator) SequencePlantuml ¶ added in v1.4.196
SequencePlantuml creates an sequence diagram and returns a plantuml url
func (*Generator) ServeHTTP ¶ added in v1.2.31
func (p *Generator) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP is implements the handler interface
func (*Generator) ServerSettings ¶ added in v1.2.31
ServerSettings sets the server settings, this should be set before using as http handler
func (*Generator) SetOptions ¶ added in v1.3.0
func (*Generator) SourcePath ¶ added in v1.4.16
func (p *Generator) SourcePath(a SourceCoder) string
SourcePath appends CurrentDir to output
func (*Generator) Update ¶ added in v1.2.31
Update loads another Sysl module into a project and runs
func (*Generator) WithRemoteTemplateString ¶ added in v1.4.196
func (*Generator) WithRetriever ¶ added in v1.4.196
func (*Generator) WithTemplateFs ¶ added in v1.4.17
func (*Generator) WithTemplateString ¶ added in v1.3.0
WithTemplateFileNames loads template strings into project and package of p respectively
type Redoc ¶ added in v1.4.50
type Redoc struct {
SpecURL string
}
Redoc is the struct passed to the string template RedocPage
type SourceCoder ¶ added in v1.4.16
type SourceCoder interface { Attr GetSourceContext() *sysl.SourceContext }