docParser

package module
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2023 License: MIT Imports: 8 Imported by: 0

README

go_graph_code_docs

Utility for generating an image graph for code documentation, helps to better depict the process of interaction of the business logic of one file with another file Output: .gv, .png, .svg

Quick start

Usage reference
package your_package

import (
	// import library
	"github.com/DaksinWorld/go_graph_code_docs"
	"github.com/DaksinWorld/go_graph_code_docs/themes"
)

func main() {
	// Specify path to folder to be parsed | name of output directory | name of file with graph
	parser := docParser.Parse("./app", "output", "graph")

	// Add title to graph, which will be generated if necessary
	parser.AddTitle("Process of node interaction")

	// Enable theme if required
	parser.AddTheme(themes.LightTheme)

	// Generate output
	parser.Generate()
}
Syntax

We specified root folder as ./app

In ./app folder we have ./routes/ folder

In ./routes/ folder we have ./routes/index.go file and ./routes/main.go, ./routes/node.go

./routes/index.go

package routes

// Because our root folder is ./app, @ in @/routes/index.go is ./app,
// So it will replace @ on ./app, in result we will have ./app/routes/index.go,
// Which is basically path from main.go file to index.go
// So we always add prefix DOC# and @ as source node,
// Then we provide path as describe above to node using -> 

// DOC# @ -> @/routes/node.go 
// DOC# @ -> @/routes/main.go

// We use DOC## to specify attributes, Name of object (could be Node or Edge) and property, for example: height: 3
// List of attributes is available describe below

// DOC## Node = height: 3
// DOC## Edge = color: red

func InitRoutes(){
    ...
}
Attributes

List of available attributes is available here

Custom attributes:

Only for Nodes!:

// DOC## Node = Description: Initialize all routes

So in result we have:

graph.png

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Parser

type Parser struct {
	Path         string
	OutputName   string
	OutputFolder string
	Title        string
	Theme        structs.Theme
}

func Parse

func Parse(path string, outputFolder string, outputName string) *Parser

func (*Parser) AddTheme added in v1.0.4

func (p *Parser) AddTheme(theme structs.Theme)

func (*Parser) AddTitle added in v1.0.4

func (p *Parser) AddTitle(title string)

func (*Parser) Generate

func (p *Parser) Generate()

Directories

Path Synopsis
app

Jump to

Keyboard shortcuts

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