diff --git a/.gaplint.yml b/.gaplint.yml new file mode 100644 index 0000000..892afe1 --- /dev/null +++ b/.gaplint.yml @@ -0,0 +1,3 @@ +disable: + - align-assignments +duplicate-function-min-length: 4 diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..fc3efd6 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,27 @@ +name: "Lint" +on: + workflow_dispatch: + pull_request: + push: + branches: + - main + - stable-*.* + schedule: + # Every day at 3:30 AM UTC + - cron: '30 3 * * *' + +jobs: + lint: + runs-on: ubuntu-latest + strategy: + fail-fast: false + steps: + - name: "Check out the repository" + uses: actions/checkout@v4 + - name: "Set up Python" + uses: actions/setup-python@v5 + - name: "Install gaplint with pip" + run: pip install gaplint + - name: "Run gaplint on the graphviz package" + run: | + gaplint gap/*.g* tst/*.tst examples/*.g* PackageInfo.g init.g read.g makedoc.g tst/testall.g diff --git a/PackageInfo.g b/PackageInfo.g index c482ace..74e51c1 100644 --- a/PackageInfo.g +++ b/PackageInfo.g @@ -1,54 +1,48 @@ # -# graphviz: This package facilitates the creation of graph descriptions in the DOT language of the Graphviz graph drawing software from GAP +# graphviz: This package facilitates the creation of graph descriptions in the +# DOT language of the Graphviz graph drawing software from GAP # # This file contains package meta data. For additional information on # the meaning and correct usage of these fields, please consult the # manual of the "Example" package as well as the comments in its # PackageInfo.g file. # -SetPackageInfo( rec( +SetPackageInfo(rec( PackageName := "graphviz", -Subtitle := "This package facilitates the creation of graph descriptions in the DOT language of the Graphviz graph drawing software from GAP", -Version := "0.1", -Date := "09/04/2022", # dd/mm/yyyy format -License := "GPL-2.0-or-later", +Subtitle := "GAP representations of graphviz objects", +Version := "0.0.0", +Date := "09/04/2022", # dd/mm/yyyy format +License := "GPL-2.0-or-later", Persons := [ rec( - FirstNames := "James D.", - LastName := "Mitchell", - WWWHome := "https://jdbm.me", - Email := "jdm3@st-andrews.ac.uk", - IsAuthor := true, - IsMaintainer := true, - PostalAddress := "Mathematical Institute, North Haugh, St Andrews, Fife, KY16 9SS, Scotland", - Place := "St Andrews", - Institution := "University of St Andrews", - ), -], + FirstNames := "James D.", + LastName := "Mitchell", + WWWHome := "https://jdbm.me", + Email := "jdm3@st-andrews.ac.uk", + IsAuthor := true, + IsMaintainer := true, + PostalAddress := Concatenation("Mathematical Institute, North Haugh,", + " St Andrews, Fife, KY16 9SS, Scotland"), + Place := "St Andrews", + Institution := "University of St Andrews")], -#SourceRepository := rec( Type := "TODO", URL := "URL" ), -#IssueTrackerURL := "TODO", -PackageWWWHome := "https://google.com", # "None/", -PackageInfoURL := "https://google.com", # Concatenation( ~.PackageWWWHome, "PackageInfo.g" ), -README_URL := "https://google.com", # Concatenation( ~.PackageWWWHome, "README.md" ), -ArchiveURL := "https://google.com", # Concatenation( ~.PackageWWWHome, - # "/", ~.PackageName, "-", ~.Version ), +SourceRepository := rec(Type := "git", + URL := "https://github.com/digraphs/graphviz"), +IssueTrackerURL := "https://github.com/digraphs/graphviz/issues", +PackageWWWHome := "TODO", +PackageInfoURL := Concatenation(~.PackageWWWHome, "PackageInfo.g"), +README_URL := Concatenation(~.PackageWWWHome, "README.md"), +ArchiveURL := Concatenation(~.PackageWWWHome, + "/", + ~.PackageName, + "-", + ~.Version), ArchiveFormats := ".tar.gz", -## Status information. Currently the following cases are recognized: -## "accepted" for successfully refereed packages -## "submitted" for packages submitted for the refereeing -## "deposited" for packages for which the GAP developers agreed -## to distribute them with the core GAP system -## "dev" for development versions of packages -## "other" for all other packages -## -Status := "dev", - -AbstractHTML := "", +AbstractHTML := "TODO", PackageDoc := rec( BookName := "graphviz", @@ -56,22 +50,16 @@ PackageDoc := rec( HTMLStart := "doc/chap0.html", PDFFile := "doc/manual.pdf", SixFile := "doc/manual.six", - LongTitle := "This package facilitates the creation of graph descriptions in the DOT language of the Graphviz graph drawing software from GAP", + LongTitle := "TODO", ), Dependencies := rec( - GAP := ">= 4.11", - NeededOtherPackages := [ ], - SuggestedOtherPackages := [ ], - ExternalConditions := [ ], + GAP := ">= 4.11.0", + NeededOtherPackages := [], + SuggestedOtherPackages := [], + ExternalConditions := [], ), AvailabilityTest := ReturnTrue, -TestFile := "tst/testall.g", - -#Keywords := [ "TODO" ], - -)); - - +TestFile := "tst/testall.g")); diff --git a/gap/dot.gi b/gap/dot.gi index 8d66bd7..5e137af 100644 --- a/gap/dot.gi +++ b/gap/dot.gi @@ -183,12 +183,8 @@ DeclareOperation("GV_Digraph", [IsGVDigraph, IsString]); DeclareOperation("GV_Context", [IsGVGraph, IsString]); DeclareOperation("GV_Map", []); -InstallMethod(GV_Map, -"for a nothing", -[], -function() - return Objectify(GV_MapType, rec(Data := rec())); -end); +InstallMethod(GV_Map, "for no args", +[], {} -> Objectify(GV_MapType, rec(Data := rec()))); InstallMethod(GV_Node, "for a string", @@ -350,19 +346,14 @@ end); InstallOtherMethod(IsBound\[\], "for a graphviz map and an object", [IsGV_Map, IsObject], -function(m, key) - return IsBound(m!.Data.(key)); -end); +{m, key} -> IsBound(m!.Data.(key))); DeclareOperation("GV_MapNames", [IsGV_Map]); -InstallMethod(GV_MapNames, -"for a graphviz map", -[IsGV_Map], -m -> RecNames(m!.Data)); -InstallMethod(ViewString, -"for a graphviz map", -[IsGV_Map], +InstallMethod(GV_MapNames, "for a graphviz map", +[IsGV_Map], m -> RecNames(m!.Data)); + +InstallMethod(ViewString, "for a graphviz map", [IsGV_Map], m -> String(m!.Data)); # ########################################################### @@ -495,10 +486,10 @@ x -> x!.Counter); # Converting strings DeclareOperation("GV_EnsureString", [IsObject]); +# TODO required? InstallMethod(GV_EnsureString, "for an object", -[IsObject], -x -> ViewString(x)); +[IsObject], ViewString); InstallMethod(GV_EnsureString, "for a string", @@ -562,9 +553,7 @@ end); InstallOtherMethod(\[\], "for a graphviz graph and string", [IsGVGraph, IsString], -function(graph, node) - return GraphvizNodes(graph)[node]; -end); +{graph, node} -> GraphvizNodes(graph)[node]); InstallOtherMethod(\[\], "for a graphviz graph and string", @@ -572,20 +561,17 @@ InstallOtherMethod(\[\], {g, o} -> g[ViewString(o)]); DeclareOperation("GV_HasNode", [IsGVGraph, IsObject]); + InstallMethod(GV_HasNode, "for a graphviz graph", [IsGVGraph, IsString], -function(g, name) - return name in GV_MapNames(GraphvizNodes(g)); -end); +{g, name} -> name in GV_MapNames(GraphvizNodes(g))); DeclareOperation("GV_GetParent", [IsGVGraph]); + InstallMethod(GV_GetParent, "for a graphviz graph", -[IsGVGraph], -function(graph) - return graph!.Parent; -end); +[IsGVGraph], graph -> graph!.Parent); DeclareOperation("GV_GraphTreeSearch", [IsGVGraph, IsFunction]); InstallMethod(GV_GraphTreeSearch, @@ -772,9 +758,10 @@ function(x, name) return node; end); +# TODO required? InstallMethod(GraphvizAddNode, "for a graphviz graph and string", [IsGVGraph, IsGVNode], -function(_, __) +function(_, __) # gaplint: disable=analyse-lvars local error; error := "Cannot add node objects directly to graphs. "; error := Concatenation(error, "Please use the node's name."); @@ -784,9 +771,7 @@ end); InstallMethod(GraphvizAddNode, "for a graphviz graph and string", [IsGVGraph, IsObject], -function(x, name) - return GraphvizAddNode(x, ViewString(name)); -end); +{x, name} -> GraphvizAddNode(x, ViewString(name))); DeclareOperation("GV_AddEdge", [IsGVGraph, IsGVEdge]); InstallMethod(GV_AddEdge, @@ -949,9 +934,7 @@ InstallMethod(GraphvizAddContext, InstallMethod(GraphvizRemoveNode, "for a graphviz graph and node", [IsGVGraph, IsGVNode], -function(g, node) - return GraphvizRemoveNode(g, GraphvizName(node)); -end); +{g, node} -> GraphvizRemoveNode(g, GraphvizName(node))); InstallMethod(GraphvizRemoveNode, "for a graphviz graph and a string", [IsGVGraph, IsString], @@ -1050,27 +1033,19 @@ end); # @ Return DOT graph head line. InstallMethod(GV_StringifyGraphHead, "for a string", [IsGVGraph], -function(graph) - return StringFormatted("graph {} {{\n", GraphvizName(graph)); -end); +graph -> StringFormatted("graph {} {{\n", GraphvizName(graph))); # @ Return DOT digraph head line. InstallMethod(GV_StringifyDigraphHead, "for a string", [IsGVDigraph], -function(graph) - return StringFormatted("digraph {} {{\n", GraphvizName(graph)); -end); +graph -> StringFormatted("digraph {} {{\n", GraphvizName(graph))); # @ Return DOT subgraph head line. InstallMethod(GV_StringifySubgraphHead, "for a string", [IsGVGraph], -function(graph) - return StringFormatted("subgraph {} {{\n", GraphvizName(graph)); -end); +graph -> StringFormatted("subgraph {} {{\n", GraphvizName(graph))); # @ Return DOT subgraph head line. InstallMethod(GV_StringifyContextHead, "for a string", [IsGVContext], -function(graph) - return StringFormatted("// {} context \n", GraphvizName(graph)); -end); +graph -> StringFormatted("// {} context \n", GraphvizName(graph))); # @ Return DOT node statement line. InstallMethod(GV_StringifyNode, "for string and record", @@ -1226,7 +1201,7 @@ InstallMethod(GV_StringifyGraph, "for a graphviz graph and a string", [IsGVGraph, IsBool], function(graph, is_subgraph) - local result, obj, tmp; + local result, obj; result := ""; # get the correct head to use @@ -1281,6 +1256,4 @@ end); InstallMethod(AsString, "for a graphviz graph", [IsGVGraph], -function(graph) - return GV_StringifyGraph(graph, false); -end); +graph -> GV_StringifyGraph(graph, false)); diff --git a/gap/splash.gi b/gap/splash.gi index 30cd1de..517e017 100644 --- a/gap/splash.gi +++ b/gap/splash.gi @@ -5,7 +5,7 @@ if not IsBound(Splash) then # This function is written by A. Egri-Nagy BindGlobal("Splash", function(arg) - local str, opt, path, dir, tdir, file, viewer, type, inn, filetype, out, + local str, opt, path, dir, tdir, file, viewer, inn, filetype, out, engine; if not IsString(arg[1]) and not IsGVGraph(arg[1]) then diff --git a/start.g b/start.g deleted file mode 100644 index 0d6d0cb..0000000 --- a/start.g +++ /dev/null @@ -1,3 +0,0 @@ -# Testing Utility File - -LoadPackage("graphviz"); \ No newline at end of file