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
- func AsSet(in []string) map[string]struct{}
- func Attribute(a Attr, query string) string
- func BuildGithubBlobURL(repoURL string) string
- func BuildGithubRawURL(repoURL string) (gitURL string)
- func BuildRedoc(specURL string) []byte
- func BuildSpecURL(source *sysl.SourceContext) (string, error)
- 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 GenerateAndWriteRedoc(fs afero.Fs, fileName string, specURL string) error
- func GetAppPackageName(a Namer) (string, string)
- func GetAppTypeName(param Typer) (appName string, typeName string)
- func GetPackageName(m *sysl.Module, a Namer) string
- func GetRemoteFromGit() (string, error)
- func HttpToFile(fs afero.Fs, fileName, url string) error
- func IsOpenAPIFile(source *sysl.SourceContext) bool
- func Last(i interface{}, ind int) bool
- func Map(vs []string, funcs ...func(string) string) []string
- func ModulePackageName(m *sysl.Module) string
- func NewTypeRef(appName, typeName string) *sysl.Type
- func PlantUMLJava(service, out string) error
- func PlantUMLNailGun(contents string) ([]byte, error)
- func PlantUMLURL(plantumlService, contents string) (string, error)
- func Remove(s string, old ...string) string
- func RetryHTTPRequest(url string) ([]byte, error)
- func SanitiseOutputName(s string) string
- func ServiceMetadata(a Attr) string
- func SortedKeys(m interface{}) []string
- func StripExtension(input string) string
- func TernaryOperator(condition bool, i ...interface{}) interface{}
- type Attr
- type Generator
- func (p *Generator) CreateAliasedTypeDiagram(appName, typeName, typeAlias string, t *sysl.Type, recursive bool) string
- func (p *Generator) CreateAliasedTypeDiagramMermaid(appName string, typeName string, typeAlias string, recursive bool) string
- func (p *Generator) CreateFile(contents string, diagramType int, elems ...string) string
- func (p *Generator) CreateIntegrationDiagram(m *sysl.Module, title string, EPA bool) string
- func (p *Generator) CreateIntegrationDiagramMermaid(m *sysl.Module, title string, EPA bool) string
- func (p *Generator) CreateIntegrationDiagramPlantuml(m *sysl.Module, title string, EPA bool) string
- func (p *Generator) CreateMarkdown(t *template.Template, outputFileName string, i interface{}) error
- func (p *Generator) CreateParamDataModel(app *sysl.Application, param Param) string
- func (p *Generator) CreateRedoc(sourceContext *sysl.SourceContext, appName string) string
- func (p *Generator) CreateReturnDataModel(appname string, stmnt *sysl.Statement, endpoint *sysl.Endpoint) string
- func (p *Generator) CreateSequenceDiagram(appName string, endpoint *sysl.Endpoint) string
- func (p *Generator) CreateSequenceDiagramMermaid(appName string, endpoint *sysl.Endpoint) string
- func (p *Generator) CreateSequenceDiagramPlantuml(appName string, endpoint *sysl.Endpoint) string
- func (p *Generator) CreateTypeDiagram(appName string, typeName string, t *sysl.Type, recursive bool) string
- func (p *Generator) GenerateDataModel(app *sysl.Application) string
- 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) 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) PUMLFile(fs afero.Fs, fileName, contents string) error
- func (p *Generator) Packages(m *sysl.Module) []string
- func (p *Generator) Run()
- func (p *Generator) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (p *Generator) ServerSettings(disableCSS, liveReload, imageTags bool) *Generator
- func (p *Generator) SetOptions(disableCss, disableImages, imageTags, redoc, mermaidEnabled bool, ...) *Generator
- func (p *Generator) SourcePath(a SourceCoder) string
- func (p *Generator) Update(m *sysl.Module, errs ...error) *Generator
- func (p *Generator) WithTemplateFs(fs afero.Fs, fileNames ...string) *Generator
- func (p *Generator) WithTemplateString(tmpls ...string) *Generator
- type MermaidGenerator
- type Namer
- type Param
- type Redoc
- type SourceCoder
- type Typer
Constants ¶
const MacroPackageProject = `` /* 434-byte string literal not displayed */
const NewPackageTemplate = `` /* 5774-byte string literal not displayed */
const ProjectTemplate = `` /* 496-byte string literal not displayed */
const RedocPage = `` /* 675-byte string literal not displayed */
Variables ¶
This section is empty.
Functions ¶
func BuildGithubBlobURL ¶ added in v1.4.107
BuildGithubBlobURL creates a root URL for github blob it will not work for non github links.
func BuildGithubRawURL ¶ added in v1.4.50
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
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
CreateFileName returns the absolute and relative filepaths
func CreateSequenceDiagram ¶
CreateSequenceDiagram creates an sequence diagram and returns the sequence diagram string and any errors
func GenerateAndWriteRedoc ¶ added in v1.4.50
GenerateRedoc creates a redoc html file
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 GetRemoteFromGit ¶ added in v1.4.50
GetRemoteFromGit gets the URL to the git remote e.g github.com/myorg/somerepo/
func IsOpenAPIFile ¶ added in v1.4.50
func IsOpenAPIFile(source *sysl.SourceContext) bool
func ModulePackageName ¶ added in v1.2.31
func NewTypeRef ¶ added in v1.2.30
NewTypeRef returns a type reference, needed to correctly generate data model diagrams
func PlantUMLJava ¶ added in v1.4.51
func PlantUMLNailGun ¶ added in v1.4.51
func PlantUMLURL ¶ added in v1.2.31
PlantUMLURL returns a PlantUML url
func RetryHTTPRequest ¶ added in v1.2.31
RetryHTTPRequest retries the given request
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 SortedKeys ¶ added in v1.3.0
func SortedKeys(m interface{}) []string
func StripExtension ¶ added in v1.4.50
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 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 (*Generator) CreateAliasedTypeDiagramMermaid ¶ added in v1.4.171
func (*Generator) CreateFile ¶ added in v1.3.0
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 (*Generator) CreateIntegrationDiagramMermaid ¶ added in v1.3.0
func (*Generator) CreateIntegrationDiagramPlantuml ¶ added in v1.3.0
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 (*Generator) CreateSequenceDiagramMermaid ¶ added in v1.4.171
func (*Generator) CreateSequenceDiagramPlantuml ¶ added in v1.4.171
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
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) 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) 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
RootPath appends CurrentDir to output
func (*Generator) Update ¶ added in v1.2.31
Update loads another Sysl module into a project and runs
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 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 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 }