catalog

package
v1.4.206 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2020 License: Apache-2.0 Imports: 40 Imported by: 0

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

View Source
const MacroPackageProject = `` /* 487-byte string literal not displayed */
View Source
const MacroPackageProjectMermaid = `` /* 602-byte string literal not displayed */
View Source
const NewPackageTemplate = `` /* 5899-byte string literal not displayed */
View Source
const NewPackageTemplateMermaid = `` /* 5514-byte string literal not displayed */
View Source
const ProjectTemplate = `` /* 486-byte string literal not displayed */
View Source
const ProjectTemplateMermaid = `` /* 600-byte string literal not displayed */
View Source
const RedocPage = `` /* 647-byte string literal not displayed */

Variables

This section is empty.

Functions

func Attribute added in v1.2.31

func Attribute(a Attr, query string) string

func BuildSpecURL added in v1.4.50

func BuildSpecURL(filePath string, version string) string

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

func CreateFileName(dir string, elems ...string) (string, string)

CreateFileName returns the absolute and relative filepaths

func CreateSequenceDiagram

func CreateSequenceDiagram(m *sysl.Module, call string) (string, error)

CreateSequenceDiagram creates an sequence diagram and returns the sequence diagram string and any errors

func FieldType added in v1.4.30

func FieldType(t *sysl.Type) string

func Fields added in v1.4.30

func Fields(t *sysl.Type) map[string]*sysl.Type

func Filter added in v1.3.0

func Filter(vs []string, f func(string) bool) []string

Map applies a function to every element in a string slice

func GetAppNameString added in v1.4.193

func GetAppNameString(a Namer) string

GetAppNameString returns an app's name as a string, with the namespace joined on "::".

func GetAppPackageName

func GetAppPackageName(a Namer) (string, string)

GetAppPackageName returns the package and app name of any sysl application

func GetAppTypeName added in v1.3.0

func GetAppTypeName(param Typer) (appName string, typeName string)

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 GetPackageName added in v1.4.131

func GetPackageName(m *sysl.Module, a Namer) string

func IsOpenAPIFile added in v1.4.50

func IsOpenAPIFile(filePath string) bool

func JoinAppNameString added in v1.4.193

func JoinAppNameString(an *sysl.AppName) string

JoinAppNameString transforms an AppName to a string, with the namespace joined on "::".

func Last added in v1.4.18

func Last(i interface{}, ind int) bool

func ModuleNamespace added in v1.4.203

func ModuleNamespace(m *sysl.Module) string

ModuleNamespace returns the namespace associated with the module (if the module is grouped by a namespace).

func ModulePackageName added in v1.2.31

func ModulePackageName(m *sysl.Module) string

ModulePackageName returns the package name associated with the module (that of one of its apps).

func NewTypeRef added in v1.2.30

func NewTypeRef(appName, typeName string) *sysl.Type

NewTypeRef returns a type reference, needed to correctly generate data model diagrams

func PlantUMLURL added in v1.2.31

func PlantUMLURL(plantumlService, contents string) string

PlantUMLURL returns a PlantUML url

func Remove added in v1.4.20

func Remove(s string, old ...string) string

func SanitiseOutputName added in v1.2.31

func SanitiseOutputName(s string) string

SanitiseOutputName removes characters so that the string can be used as a hyperlink.

func ServiceMetadata added in v1.4.103

func ServiceMetadata(a Attr) string

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

func UnmarshallJson added in v1.4.185

func UnmarshallJson(b []byte, m *sysl.Module) error

Unmarshall Json unmarshalls json bytes into a sysl module

Types

type Attr added in v1.3.0

type Attr interface {
	GetAttrs() map[string]*sysl.Attribute
}

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 (p *Generator) AutomaticTemplates(fs afero.Fs, fileNames ...string) *Generator

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 (p *Generator) DataModelMermaid(appName, typeName string) string

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 (p *Generator) DataModelPlantuml(appName, typeName string, t *sysl.Type, recursive bool) string

func (*Generator) DataModelReturnMermaid added in v1.4.196

func (p *Generator) DataModelReturnMermaid(appName string, stmnt *sysl.Statement, endpoint *sysl.Endpoint) string

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

func (p *Generator) DataModelTable(appName, typeName, aliasName string) string

DataModelTable prints out a markdown table which describes a type

func (*Generator) ExtractReturnInfo added in v1.4.196

func (p *Generator) ExtractReturnInfo(appname string, stmnt *sysl.Statement, endpoint *sysl.Endpoint) (appName string, typeName string, typeref *sysl.Type, getRecursive bool)

func (*Generator) ExtractTypeInfo added in v1.4.196

func (p *Generator) ExtractTypeInfo(app *sysl.Application, param Param) (appName, typeName, aliasTypeName string, getRecursive bool)

func (*Generator) GetFuncMap added in v1.2.31

func (p *Generator) GetFuncMap() template.FuncMap

GetFuncMap returns the funcs that are used in diagram generation.

func (*Generator) GetParamType added in v1.2.31

func (p *Generator) GetParamType(app *sysl.Application, param *sysl.Param) *sysl.Type

GetReturnType converts an application and a param into a type, useful for getting attributes.

func (*Generator) GetReturnType added in v1.2.31

func (p *Generator) GetReturnType(endpoint *sysl.Endpoint, stmnt *sysl.Statement) *sysl.Type

GetReturnType converts an endpoint and a statement into a type, useful for getting attributes.

func (*Generator) IntegrationMermaid added in v1.4.196

func (p *Generator) IntegrationMermaid(m *sysl.Module, title string, EPA bool) string

func (*Generator) IntegrationPlantuml added in v1.4.196

func (p *Generator) IntegrationPlantuml(m *sysl.Module, title string, EPA bool) string

IntegrationPlantuml creates an integration diagram and returns the plantuml string

func (*Generator) MacroPackages added in v1.4.17

func (p *Generator) MacroPackages(module *sysl.Module) []string

MacroPackages executes the markdown for a MacroPackage and returns a slice of the rows

func (*Generator) ModuleAsMacroPackage added in v1.3.0

func (p *Generator) ModuleAsMacroPackage(m *sysl.Module) map[string]*sysl.Module

func (*Generator) ModuleAsPackages added in v1.3.0

func (p *Generator) ModuleAsPackages(m *sysl.Module) map[string]*sysl.Module

ModuleAsPackages returns a map of [packagename]*sysl.Module

func (*Generator) Packages added in v1.4.17

func (p *Generator) Packages(m *sysl.Module) []string

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 (p *Generator) SequenceMermaid(appName string, endpoint *sysl.Endpoint) string

func (*Generator) SequencePlantuml added in v1.4.196

func (p *Generator) SequencePlantuml(appName string, endpoint *sysl.Endpoint) string

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

func (p *Generator) ServerSettings(disableCSS, liveReload, imageTags bool) *Generator

ServerSettings sets the server settings, this should be set before using as http handler

func (*Generator) SetOptions added in v1.3.0

func (p *Generator) SetOptions(
	disableCss bool,
	readmeName, ImageDest string) *Generator

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

func (p *Generator) Update(m *sysl.Module, errs ...error) *Generator

Update loads another Sysl module into a project and runs

func (*Generator) WithRemoteTemplateString added in v1.4.196

func (p *Generator) WithRemoteTemplateString(remoteResources ...string) *Generator

func (*Generator) WithRetriever added in v1.4.196

func (p *Generator) WithRetriever(retr gop.Retriever) *Generator

func (*Generator) WithTemplateFs added in v1.4.17

func (p *Generator) WithTemplateFs(fs afero.Fs, fileNames ...string) *Generator

func (*Generator) WithTemplateString added in v1.3.0

func (p *Generator) WithTemplateString(tmpls ...string) *Generator

WithTemplateFileNames loads template strings into project and package of p respectively

type Namer added in v1.3.0

type Namer interface {
	Attr
	GetName() *sysl.AppName
}

type Param added in v1.4.123

type Param interface {
	Typer
	GetName() string
}

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
}

type Typer added in v1.3.0

type Typer interface {
	GetType() *sysl.Type
}

Jump to

Keyboard shortcuts

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