Skip to content

Commit

Permalink
Update DocumentParser.lua from the apply_all_options branch and bug f…
Browse files Browse the repository at this point in the history
…ix ControlElectric.lua
  • Loading branch information
hansonchar committed Jun 23, 2024
1 parent 9e55d0e commit 19d67f6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 43 deletions.
22 changes: 9 additions & 13 deletions tex/generic/pgf/graphdrawing/lua/pgf/gd/force/ControlElectric.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ declare {
type = "number",
initial = 1,

summary = [["
summary = [[
Defines the electric charge of the node. The stronger the
|electric charge| of a node the stronger the repulsion between the
node and others in the graph. A negative |electric charge| means that
Expand All @@ -38,25 +38,21 @@ declare {
|spring electrical layout| algorithm works.
Two typical effects of increasing the |electric charge| are distortion
of symmetries and an upscaling of the drawings.
"]],
]],
examples = {
{
options = [["preamble={\usetikzlibrary{graphs,graphdrawing} \usegdlibrary{force}}"]],
code = [["
options = [[ preamble={\usetikzlibrary{graphs,graphdrawing} \usegdlibrary{force}} ]],
[[
\tikz \graph [spring electrical layout, horizontal=0 to 1]
{ 0 [electric charge=1] -- subgraph C_n [n=10] };
"]]
},{
code = [["
]],
[[
\tikz \graph [spring electrical layout, horizontal=0 to 1]
{ 0 [electric charge=5] -- subgraph C_n [n=10] };
"]]
},{
code = [["
]],
[[
\tikz \graph [spring electrical layout, horizontal=0 to 1]
{ [clique] 1 [electric charge=5], 2, 3, 4 };
"]]
}
]]
}
}

Expand Down
33 changes: 3 additions & 30 deletions tex/generic/pgf/lua/pgf/manual/DocumentParser.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,6 @@ local DocumentParser = {
renderers = {}
}

local DEBUG = false

local function dump(t)
print("*** dump starts ... {")
for key, val in pairs(t) do
print("*** dump/key:", key, "val:", val)
end
-- for i, e in ipairs(t) do
-- print("*** dump/", i, e)
-- end
print("*** dump ends }")
end

-- Namespace:
require 'pgf.manual'.DocumentParser = DocumentParser

Expand Down Expand Up @@ -166,33 +153,19 @@ local function process_examples(t)
return nil
end

local options
if type(t) == "string" then
if DEBUG then print("*** process_examples/t is string:", t) end
t = {t}
else
if DEBUG then
print("*** process_examples/t is table:", t)
dump(t)
end
options = t.options
if DEBUG then print("*** process_examples/options:", options) end
end

local n = {}
if DEBUG then print("*** #t:", #t) end
for i=1,#t do
local code
local code, options
if type(t[i]) == "table" then
if DEBUG then
print("*** t[i].code:", i, t[i].code)
print("*** t[i].options:", i, t[i].options)
end
code = assert(t[i].code)
options = t[i].options
options = t[i].options or t.options
else
if DEBUG then print("*** t[i]:", i, t[i]) end
code = t[i]
options = t.options
end
n[i] = {
options = process_string(strip_quotes(options)),
Expand Down

0 comments on commit 19d67f6

Please sign in to comment.