Skip to content

Commit

Permalink
Additional changes in response to the feedback at
Browse files Browse the repository at this point in the history
  #1335

Signed-off-by: Hanson Char <[email protected]>
  • Loading branch information
hansonchar committed Jun 6, 2024
1 parent 5f1f861 commit 0c8e059
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 23 deletions.
66 changes: 49 additions & 17 deletions tex/generic/pgf/graphdrawing/lua/pgf/gd/control/doc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,12 @@ sense that some nodes are ``nailed to the canvas'' while other
nodes can ``move freely''.
]]

--[[
% TODOsp: codeexamples: the following 3 examples need these libraries
% \usetikzlibrary{graphs,graphdrawing}
% \usegdlibrary{force}
--]]
example
example({options =
[[
preamble=\usetikzlibrary{graphs,graphdrawing}
\usegdlibrary{force}
]],
code =
[[
\begin{tikzpicture}
\draw [help lines] (0,0) grid (3,2);
Expand All @@ -114,8 +114,14 @@ example
};
\end{tikzpicture}
]]
})

example
example({options =
[[
preamble=\usetikzlibrary{graphs,graphdrawing}
\usegdlibrary{force}
]],
code =
[[
\begin{tikzpicture}
\draw [help lines] (0,0) grid (3,2);
Expand All @@ -126,8 +132,14 @@ example
};
\end{tikzpicture}
]]
})

example
example({options =
[[
preamble=\usetikzlibrary{graphs,graphdrawing}
\usegdlibrary{force}
]],
code =
[[
\begin{tikzpicture}
\draw [help lines] (0,0) grid (3,2);
Expand All @@ -138,6 +150,7 @@ example
};
\end{tikzpicture}
]]
})
--------------------------------------------------------------------


Expand Down Expand Up @@ -167,20 +180,26 @@ Note how in the last example |c| is placed at |(1,1)| rather than
|b| as would happen by default.
]]

--[[
% TODOsp: codeexamples: the following 4 examples need these libraries
% \usetikzlibrary{graphs,graphdrawing}
% \usegdlibrary{layered}
--]]
example
example({options =
[[
preamble=\usetikzlibrary{graphs,graphdrawing}
\usegdlibrary{layered}
]],
code =
[[
\tikz \draw (0,0)
-- (1,0.5) graph [edges=red, layered layout, anchor node=a] { a -> {b,c} }
-- (1.5,0) graph [edges=blue, layered layout,
anchor node=y, anchor at={(2,0)}] { x -> {y,z} };
]]
})

example
example({options =
[[
preamble=\usetikzlibrary{graphs,graphdrawing}
\usegdlibrary{layered}
]],
code =
[[
\begin{tikzpicture}
\draw [help lines] (0,0) grid (3,2);
Expand All @@ -189,6 +208,7 @@ example
{ a -- {b [x=1,y=1], c [x=1,y=1] } -- d -- a};
\end{tikzpicture}
]]
})
--------------------------------------------------------------------


Expand All @@ -203,7 +223,12 @@ The coordinate at which the graph should be anchored when no
explicit anchor is given for any node. The initial value is the origin.
]]

example
example({options =
[[
preamble=\usetikzlibrary{graphs,graphdrawing}
\usegdlibrary{layered}
]],
code =
[[
\begin{tikzpicture}
\draw [help lines] (0,0) grid (2,2);
Expand All @@ -212,6 +237,7 @@ example
{ a -- {b, c [anchor here] } -- d -- a};
\end{tikzpicture}
]]
})
--------------------------------------------------------------------


Expand All @@ -233,7 +259,12 @@ In the example, |c| is placed at the origin since this is the
default |anchor at| position.
]]

example
example({options =
[[
preamble=\usetikzlibrary{graphs,graphdrawing}
\usegdlibrary{layered}
]],
code =
[[
\begin{tikzpicture}
\draw [help lines] (0,0) grid (2,2);
Expand All @@ -242,4 +273,5 @@ example
{ a -- {b, c [anchor here] } -- d -- a};
\end{tikzpicture}
]]
})
--------------------------------------------------------------------
7 changes: 3 additions & 4 deletions tex/generic/pgf/graphdrawing/lua/pgf/gd/doc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,10 @@ end
-- Adds an example to the |examples| field of the last key selected
-- through the |key| command.
--
-- @param string An additional example string.

function doc.example (string)
-- @param input either a string of example or a table with two fields - "code" and "options".
function doc.example (input)
local examples = rawget(current_key, "examples") or {}
examples[#examples + 1] = string
examples[#examples + 1] = input
current_key.examples = examples
end

Expand Down
8 changes: 6 additions & 2 deletions tex/generic/pgf/graphdrawing/lua/pgf/gd/trees/doc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -293,9 +293,12 @@ example
};
]]

example
example({options =
[[
preamble=\usetikzlibrary{shapes.misc, arrows.meta, decorations.pathmorphing}
]],
code =
[[
\usetikzlibrary{shapes.misc, arrows.meta, decorations.pathmorphing}
\tikz \graph [binary tree layout] {
Knuth -> {
Beeton -> Kellermann [second] -> Carnes,
Expand All @@ -313,6 +316,7 @@ example
}
};
]]
})
--------------------------------------------------------------------


Expand Down

0 comments on commit 0c8e059

Please sign in to comment.