Skip to content

Commit

Permalink
Linting
Browse files Browse the repository at this point in the history
  • Loading branch information
james-d-mitchell committed May 2, 2024
1 parent 9bf7378 commit 1911ae7
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 102 deletions.
3 changes: 3 additions & 0 deletions .gaplint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
disable:
- align-assignments
duplicate-function-min-length: 4
27 changes: 27 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -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
82 changes: 35 additions & 47 deletions PackageInfo.g
Original file line number Diff line number Diff line change
@@ -1,77 +1,65 @@
#
# 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",
ArchiveURLSubset := ["doc"],
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"));
75 changes: 24 additions & 51 deletions gap/dot.gi
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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));

# ###########################################################
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -562,30 +553,25 @@ 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",
[IsGVGraph, IsObject],
{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,
Expand Down Expand Up @@ -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.");
Expand All @@ -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,
Expand Down Expand Up @@ -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],
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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));
2 changes: 1 addition & 1 deletion gap/splash.gi
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions start.g

This file was deleted.

0 comments on commit 1911ae7

Please sign in to comment.