catalog

package
v1.4.118 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2020 License: Apache-2.0 Imports: 39 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

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

Index

Constants

View Source
const MacroPackageProject = `` /* 514-byte string literal not displayed */
View Source
const NewPackageTemplate = `` /* 5810-byte string literal not displayed */
View Source
const ProjectTemplate = `` /* 575-byte string literal not displayed */
View Source
const RedocPage = `` /* 639-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 BuildGithubBlobURL added in v1.4.107

func BuildGithubBlobURL(repoURL string) string

BuildGithubBlobURL creates a root URL for github blob it will not work for non github links.

func BuildGithubRawURL added in v1.4.50

func BuildGithubRawURL(repoURL string) (gitURL string)

BuildGithubRawURL gets the base URL for raw content hosted on github.com or Github Enterprise For github.com it takes in https://github.com/anz-bank/sysl-catalog and returns https://raw.githubusercontent.com/anz-bank/sysl-catalog/master/ For Github Enterprise it takes in https://github.myorg.com/anz-bank/sysl-catalog and returns https://github.myorg.com/raw/anz-bank/sysl-catalog/master/

func BuildRedoc added in v1.4.50

func BuildRedoc(specURL string) []byte

BuildRedoc generates a slice of bytes containing the HTML contents of a redoc page It takes in the url where the spec is located

func BuildSpecURL added in v1.4.50

func BuildSpecURL(source *sysl.SourceContext) string

BuildSpecURL takes a source context reference and builds an raw git URL for it It handles sourceContext paths which are from remote repos as well as in the same repo

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

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

GenerateAndWriteMermaidDiagram writes a mermaid svg to file

func GenerateAndWriteRedoc added in v1.4.50

func GenerateAndWriteRedoc(fs afero.Fs, fileName string, specURL string) error

GenerateRedoc creates a redoc html 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) (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 GetRemoteFromGit added in v1.4.50

func GetRemoteFromGit() string

GetRemoteFromGit gets the URL to the git remote e.g github.com/myorg/somerepo/

func HttpToFile added in v1.2.31

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

func IsOpenAPIFile added in v1.4.50

func IsOpenAPIFile(source *sysl.SourceContext) bool

func Last added in v1.4.18

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

func Map added in v1.2.31

func Map(vs []string, funcs ...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 PlantUMLJava added in v1.4.51

func PlantUMLJava(service, out string) error

func PlantUMLNailGun added in v1.4.51

func PlantUMLNailGun(contents string) ([]byte, error)

func PlantUMLURL added in v1.2.31

func PlantUMLURL(plantumlService, contents string) (string, error)

PlantUMLURL returns a PlantUML url

func Remove added in v1.4.20

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

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 ServiceMetadata added in v1.4.103

func ServiceMetadata(a Attr) string

func SortedKeys added in v1.3.0

func SortedKeys(m interface{}) []string

func StripExtension added in v1.4.50

func StripExtension(input string) string

StripExtension removes spaces and suffixes

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 {
	RootModule           *sysl.Module
	FilesToCreate        map[string]string
	MermaidFilesToCreate map[string]string
	RedocFilesToCreate   map[string]string
	SourceFileName       string
	ProjectTitle         string
	ImageDest            string // Output all images into this folder is set
	Format               string // "html" or "markdown" or "" if custom
	Ext                  string
	OutputFileName       string
	PlantumlService      string
	Templates            []*template.Template
	StartTemplateIndex   int

	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
	Redoc         bool // used for generating redoc for openapi specs

	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
	FeedbackLink string
	ChatLink     string
	Links        map[string]string
	Server       bool
	// contains filtered or unexported fields
}

Generator is the contextual object that is used in the markdown generation

func NewProject

func NewProject(
	titleAndFileName, plantumlService, outputType, feedbackLink, chatLink 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 (*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 Typer) string

CreateParamDataModel creates a parameter data model and returns a filename

func (*Generator) CreateRedoc added in v1.4.50

func (p *Generator) CreateRedoc(sourceContext *sysl.SourceContext, appName string) string

CreateRedoc registers a file that needs to be created when the input source context has extension .json or .yaml

func (*Generator) CreateReturnDataModel added in v1.2.31

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

CreateTypeDiagram creates a data model diagram and returns the filename It handles recursively getting the related types, or for primitives, just returns the

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 (p *Generator) GetChatLink() string
func (p *Generator) GetFeedbackLink() string

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) 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) PUMLFile added in v1.4.51

func (p *Generator) PUMLFile(fs afero.Fs, fileName, contents string) error

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) 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, imageTags, redoc, mermaidEnabled bool,
	readmeName, ImageDest string) *Generator

func (*Generator) SourcePath added in v1.4.16

func (p *Generator) SourcePath(a SourceCoder) string

RootPath 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) 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 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