From cd2d616ae25b0aefd532662c003236004b09734c Mon Sep 17 00:00:00 2001 From: Javier Feliu Date: Tue, 16 May 2023 08:55:18 -0400 Subject: [PATCH 1/2] issue-154 - Added information in the README file to assist on rendering the diagrams locally or by using the online server from plantuml --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index e2ecd02..cfa9bdf 100644 --- a/README.md +++ b/README.md @@ -202,3 +202,8 @@ testingsupport.MyStruct3 o-- testingsupport.MyStruct1 ### Diagram using www.dumels.com [UML Diagram](https://www.dumels.com/diagram/23ff0222-e93b-4e9f-a4ef-4d5d9b7a5c7d) + +### Diagram rendered in plantuml online server +[UML Diagram](https://www.plantuml.com/plantuml/uml/SoWkIImgAStDuSfBp4qjBaXCJbKeIIqkoSnBBoujACWlAb6evb80WioyajIYD92qRwKdd0sIX09TXRJyV0rDXQJy_1mki6Wjc4pEIImk1ceABYagJIunLB2nKT08rd4iB4tCJIpAp4lLLB2p8zaO8np6uDHWJAozN70HRGMt_7o4ms6EgUL23HyzXDUqT7KLS4WQSM5gGmIZJGrkdOOOEX5-oiUhpI4rBmKOim00) + +For instructions on how to render these diagrams locally using plantuml please visit [https://plantuml.com](https://plantuml.com) \ No newline at end of file From 4a84cec1643ced7fbe1da6c6cea66124136a240e Mon Sep 17 00:00:00 2001 From: Javier Feliu Date: Tue, 16 May 2023 09:15:07 -0400 Subject: [PATCH 2/2] issue - ran gofmt -s --- parser/alias.go | 4 +-- parser/class_parser.go | 1 - parser/field.go | 6 ++--- parser/function.go | 4 +-- parser/struct.go | 26 +++++++++---------- .../connectionlabels/connectionlabels.go | 6 ++--- testingsupport/main.go | 2 +- testingsupport/renderingoptions/testfile.go | 2 +- testingsupport/subfolder/subfolder.go | 2 +- testingsupport/subfolder2/subfolder2.go | 4 +-- testingsupport/subfolder3/subfolder3.go | 2 +- 11 files changed, 29 insertions(+), 30 deletions(-) diff --git a/parser/alias.go b/parser/alias.go index bf860ff..b3f4ee4 100644 --- a/parser/alias.go +++ b/parser/alias.go @@ -2,7 +2,7 @@ package parser import "fmt" -//Alias defines a type that is an alias for some other type +// Alias defines a type that is an alias for some other type type Alias struct { Name string PackageName string @@ -20,7 +20,7 @@ func getNewAlias(name, packageName, aliasOf string) *Alias { } } -//AliasSlice implement the sort.Interface interface to allow for proper sorting of an alias slice +// AliasSlice implement the sort.Interface interface to allow for proper sorting of an alias slice type AliasSlice []Alias // Len is the number of elements in the collection. diff --git a/parser/class_parser.go b/parser/class_parser.go index 7526b00..9a55b93 100644 --- a/parser/class_parser.go +++ b/parser/class_parser.go @@ -10,7 +10,6 @@ call the Render() function and this will return a string with the class diagram. See github.com/jfeliu007/goplantuml/cmd/goplantuml/main.go for a command that uses this functions and outputs the text to the console. - */ package parser diff --git a/parser/field.go b/parser/field.go index fb25a88..e60df4d 100644 --- a/parser/field.go +++ b/parser/field.go @@ -9,15 +9,15 @@ import ( const packageConstant = "{packageName}" -//Field can hold the name and type of any field +// Field can hold the name and type of any field type Field struct { Name string Type string FullType string } -//Returns a string representation of the given expression if it was recognized. -//Refer to the implementation to see the different string representations. +// Returns a string representation of the given expression if it was recognized. +// Refer to the implementation to see the different string representations. func getFieldType(exp ast.Expr, aliases map[string]string) (string, []string) { switch v := exp.(type) { case *ast.Ident: diff --git a/parser/function.go b/parser/function.go index 994325c..81626a2 100644 --- a/parser/function.go +++ b/parser/function.go @@ -5,7 +5,7 @@ import ( "reflect" ) -//Function holds the signature of a function with name, Parameters and Return values +// Function holds the signature of a function with name, Parameters and Return values type Function struct { Name string Parameters []*Field @@ -14,7 +14,7 @@ type Function struct { FullNameReturnValues []string } -//SignturesAreEqual Returns true if the two functions have the same signature (parameter names are not checked) +// SignturesAreEqual Returns true if the two functions have the same signature (parameter names are not checked) func (f *Function) SignturesAreEqual(function *Function) bool { result := true result = result && (function.Name == f.Name) diff --git a/parser/struct.go b/parser/struct.go index 1383775..b7f10a1 100644 --- a/parser/struct.go +++ b/parser/struct.go @@ -5,8 +5,8 @@ import ( "unicode" ) -//Struct represent a struct in golang, it can be of Type "class" or "interface" and can be associated -//with other structs via Composition and Extends +// Struct represent a struct in golang, it can be of Type "class" or "interface" and can be associated +// with other structs via Composition and Extends type Struct struct { PackageName string Functions []*Function @@ -38,9 +38,9 @@ func (st *Struct) ImplementsInterface(inter *Struct) bool { return true } -//AddToComposition adds the composition relation to the structure. We want to make sure that *ExampleStruct -//gets added as ExampleStruct so that we can properly build the relation later to the -//class identifier +// AddToComposition adds the composition relation to the structure. We want to make sure that *ExampleStruct +// gets added as ExampleStruct so that we can properly build the relation later to the +// class identifier func (st *Struct) AddToComposition(fType string) { if len(fType) == 0 { return @@ -51,9 +51,9 @@ func (st *Struct) AddToComposition(fType string) { st.Composition[fType] = struct{}{} } -//AddToExtends Adds an extends relationship to this struct. We want to make sure that *ExampleStruct -//gets added as ExampleStruct so that we can properly build the relation later to the -//class identifier +// AddToExtends Adds an extends relationship to this struct. We want to make sure that *ExampleStruct +// gets added as ExampleStruct so that we can properly build the relation later to the +// class identifier func (st *Struct) AddToExtends(fType string) { if len(fType) == 0 { return @@ -64,18 +64,18 @@ func (st *Struct) AddToExtends(fType string) { st.Extends[fType] = struct{}{} } -//AddToAggregation adds an aggregation type to the list of aggregations +// AddToAggregation adds an aggregation type to the list of aggregations func (st *Struct) AddToAggregation(fType string) { st.Aggregations[fType] = struct{}{} } -//addToPrivateAggregation adds an aggregation type to the list of aggregations for private members +// addToPrivateAggregation adds an aggregation type to the list of aggregations for private members func (st *Struct) addToPrivateAggregation(fType string) { st.PrivateAggregations[fType] = struct{}{} } -//AddField adds a field into this structure. It parses the ast.Field and extract all -//needed information +// AddField adds a field into this structure. It parses the ast.Field and extract all +// needed information func (st *Struct) AddField(field *ast.Field, aliases map[string]string) { theType, fundamentalTypes := getFieldType(field.Type, aliases) theType = replacePackageConstant(theType, "") @@ -103,7 +103,7 @@ func (st *Struct) AddField(field *ast.Field, aliases map[string]string) { } } -//AddMethod Parse the Field and if it is an ast.FuncType, then add the methods into the structure +// AddMethod Parse the Field and if it is an ast.FuncType, then add the methods into the structure func (st *Struct) AddMethod(method *ast.Field, aliases map[string]string) { f, ok := method.Type.(*ast.FuncType) if !ok { diff --git a/testingsupport/connectionlabels/connectionlabels.go b/testingsupport/connectionlabels/connectionlabels.go index 3702775..3986c2a 100644 --- a/testingsupport/connectionlabels/connectionlabels.go +++ b/testingsupport/connectionlabels/connectionlabels.go @@ -1,11 +1,11 @@ package connectionlabels -//AbstractInterface for testing purposes +// AbstractInterface for testing purposes type AbstractInterface interface { interfaceFunction() bool } -//ImplementsAbstractInterface for testing purposes +// ImplementsAbstractInterface for testing purposes type ImplementsAbstractInterface struct { AliasOfInt PublicUse AbstractInterface @@ -15,5 +15,5 @@ func (iai *ImplementsAbstractInterface) interfaceFunction() bool { return true } -//AliasOfInt for testing purposes +// AliasOfInt for testing purposes type AliasOfInt int diff --git a/testingsupport/main.go b/testingsupport/main.go index ffc4da0..1a33bef 100644 --- a/testingsupport/main.go +++ b/testingsupport/main.go @@ -18,5 +18,5 @@ type myInt int var globalVariable int -//TestComplicatedAlias for testing purposes only +// TestComplicatedAlias for testing purposes only type TestComplicatedAlias func(strings.Builder) bool diff --git a/testingsupport/renderingoptions/testfile.go b/testingsupport/renderingoptions/testfile.go index 21af543..992de2e 100644 --- a/testingsupport/renderingoptions/testfile.go +++ b/testingsupport/renderingoptions/testfile.go @@ -1,6 +1,6 @@ package renderingoptions -//Test is for testing purposes +// Test is for testing purposes type Test struct { integer int } diff --git a/testingsupport/subfolder/subfolder.go b/testingsupport/subfolder/subfolder.go index 5edba3a..62c8198 100644 --- a/testingsupport/subfolder/subfolder.go +++ b/testingsupport/subfolder/subfolder.go @@ -5,6 +5,6 @@ type test2 interface { test() } -//TestInterfaceAsField testing interface +// TestInterfaceAsField testing interface type TestInterfaceAsField interface { } diff --git a/testingsupport/subfolder2/subfolder2.go b/testingsupport/subfolder2/subfolder2.go index 1c69e5f..cbea017 100644 --- a/testingsupport/subfolder2/subfolder2.go +++ b/testingsupport/subfolder2/subfolder2.go @@ -1,10 +1,10 @@ package subfolder2 -//Subfolder2 structure for testing purpose only +// Subfolder2 structure for testing purpose only type Subfolder2 struct { } -//SubfolderFunction is for testing purposes +// SubfolderFunction is for testing purposes func (s *Subfolder2) SubfolderFunction(b bool, i int) bool { return true } diff --git a/testingsupport/subfolder3/subfolder3.go b/testingsupport/subfolder3/subfolder3.go index e85bd2e..d2d28ea 100644 --- a/testingsupport/subfolder3/subfolder3.go +++ b/testingsupport/subfolder3/subfolder3.go @@ -1,6 +1,6 @@ package subfolder3 -//SubfolderInterface for testing purposes +// SubfolderInterface for testing purposes type SubfolderInterface interface { SubfolderFunction(bool, int) bool }