catalog

package
v1.4.174 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2020 License: Apache-2.0 Imports: 45 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 = `` /* 434-byte string literal not displayed */
View Source
const NewPackageTemplate = `` /* 5774-byte string literal not displayed */
View Source
const ProjectTemplate = `` /* 496-byte string literal not displayed */
View Source
const RedocPage = `` /* 675-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, error)

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

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

func GetRemoteFromGit added in v1.4.50

func GetRemoteFromGit() (string, error)

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
	GeneratedFiles       map[string][]byte
	GeneratedFilesMutex  *sync.RWMutex
	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
	FilterPackage        []string // Filter these regex terms out of packagenames

	CustomTemplate bool
	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
	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 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) CreateAliasedTypeDiagram added in v1.4.123

func (p *Generator) CreateAliasedTypeDiagram(appName, typeName, typeAlias string, t *sysl.Type, recursive bool) string

func (*Generator) CreateAliasedTypeDiagramMermaid added in v1.4.171

func (p *Generator) CreateAliasedTypeDiagramMermaid(appName string, typeName string, typeAlias string, recursive bool) string

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

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

func (*Generator) CreateSequenceDiagramMermaid added in v1.4.171

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

func (*Generator) CreateSequenceDiagramPlantuml added in v1.4.171

func (p *Generator) CreateSequenceDiagramPlantuml(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 (*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 MermaidGenerator added in v1.4.171

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

func MakeMermaidGenerator added in v1.4.171

func MakeMermaidGenerator() MermaidGenerator

func (MermaidGenerator) GenerateAndWriteMermaidDiagram added in v1.4.171

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

GenerateAndWriteMermaidDiagram writes a mermaid svg to file

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