catalog

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: May 12, 2020 License: Apache-2.0 Imports: 30 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)

markdown-template.go: the markdown template used to template the sysl module

server.go: implements http handler interface so that Generator struct can be used directly as a handler

util.go: misc functions to convert/send http requests/sort maps

Index

Constants

View Source
const NewPackageTemplate = `` /* 2921-byte string literal not displayed */
View Source
const NewProjectTemplate = `` /* 371-byte string literal not displayed */

Variables

This section is empty.

Functions

func AsSet added in v1.3.0

func AsSet(in []string) map[string]struct{}

func Attribute added in v1.2.31

func Attribute(a Attr, query string) string

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 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 GenerateAndWriteMermaidDiagram added in v1.3.0

func GenerateAndWriteMermaidDiagram(fs afero.Fs, fileName string, data string) error

GenerateAndWriteMermaidDiagram writes a mermaid svg to file

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) (string, string)

GetAppTypeName returns the appName and typeName of a param

func HttpToFile added in v1.2.31

func HttpToFile(fs afero.Fs, fileName, url string) error

func Map added in v1.2.31

func Map(vs []string, f func(string) string) []string

Map applies a function to every element in a string slice

func ModulePackageName added in v1.2.31

func ModulePackageName(m *sysl.Module) string

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, error)

PlantUMLURL returns a PlantUML url

func RetryHTTPRequest added in v1.2.31

func RetryHTTPRequest(url string) ([]byte, error)

RetryHTTPRequest retries the given request

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 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 Attr added in v1.3.0

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

type Generator added in v1.2.31

type Generator struct {
	FilesToCreate        map[string]string
	MermaidFilesToCreate map[string]string
	SourceFileName       string
	Title                string
	LiveReload           bool // Add live reload javascript to html
	ImageTags            bool // embedded plantuml img tags, or generated svgs
	DisableCss           bool // used for rendering raw markdown
	DisableImages        bool // used for omitting image creation
	Mermaid              bool
	Format               string // "html" or "markdown" or "" if custom
	CurrentDir           string
	Ext                  string
	OutputDir            string
	OutputFileName       string
	PlantumlService      string
	Log                  *logrus.Logger
	Fs                   afero.Fs
	Module               *sysl.Module

	ProjectTempl *template.Template
	PackageTempl *template.Template
	// 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,
	log *logrus.Logger,
	module *sysl.Module,
	fs afero.Fs, outputDir string, mermaidEnabled bool) *Generator

NewProject generates a Generator object, fs and outputDir are optional if being used for a web server.

func (*Generator) CreateFile added in v1.3.0

func (p *Generator) CreateFile(contents string, diagramType int, elems ...string) string

CreateFile registers a file that needs to be created in p, or returns the embedded img tag if in server mode

func (*Generator) CreateIntegrationDiagram added in v1.2.31

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

func (*Generator) CreateIntegrationDiagramMermaid added in v1.3.0

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

TODO @ashwinsajiv: fill out this function to generate mermaid integration diagrams

func (*Generator) CreateIntegrationDiagramPlantuml added in v1.3.0

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

CreateIntegrationDiagram creates an integration diagram and returns the filename

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) CreateParamDataModel added in v1.2.31

func (p *Generator) CreateParamDataModel(app *sysl.Application, param *sysl.Param) string

CreateParamDataModel creates a parameter data model and returns a filename

func (*Generator) CreatePathParamDataModel added in v1.2.31

func (p *Generator) CreatePathParamDataModel(CurrentAppName string, param *sysl.Endpoint_RestParams_QueryParam) string

CreateQueryParamDataModel returns a Path Parameter data model filename.

func (*Generator) CreateQueryParamDataModel added in v1.2.31

func (p *Generator) CreateQueryParamDataModel(CurrentAppName string, param *sysl.Endpoint_RestParams_QueryParam) string

CreateQueryParamDataModel returns a Query Parameter data model filename.

func (*Generator) CreateReturnDataModel added in v1.2.31

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

CreateReturnDataModel creates a return data model and returns a filename, or empty string if it wasn't a return statement.

func (*Generator) CreateSequenceDiagram added in v1.2.31

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

CreateSequenceDiagram creates an sequence diagram and returns the filename

func (*Generator) CreateTypeDiagram added in v1.2.31

func (p *Generator) CreateTypeDiagram(app *sysl.Application, typeName string, t *sysl.Type, recursive bool) string

CreateTypeDiagram creates a data model diagram and returns the filename

func (*Generator) GenerateDataModel added in v1.2.31

func (p *Generator) GenerateDataModel(app *sysl.Application) string

GenerateDataModel generates a data model for all of the types in app

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) GetRows added in v1.3.0

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

GetRows returns a slice of rows that should be output on the index pages of the markdown

func (*Generator) ModuleAsMacroPackage added in v1.3.0

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

func (*Generator) ModuleAsPackages added in v1.3.0

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

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) 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, disableImages bool) *Generator

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) WithTemplateFiles added in v1.3.0

func (p *Generator) WithTemplateFiles(p1, p2 afero.File) *Generator

WithTemplateFileNames loads templates from fs registered in p

func (*Generator) WithTemplateString added in v1.3.0

func (p *Generator) WithTemplateString(p1, p2 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 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