From 6ea5033686f1f948756c6524fb19b72aab31613b Mon Sep 17 00:00:00 2001 From: Hanson Char Date: Sat, 8 Jun 2024 13:20:36 -0700 Subject: [PATCH] Code format changes based on review feedback Signed-off-by: Hanson Char --- doc/generic/pgf/CHANGELOG.md | 2 +- .../graphdrawing/lua/pgf/gd/control/doc.lua | 170 ++++++++---------- .../pgf/graphdrawing/lua/pgf/gd/trees/doc.lua | 43 +++-- 3 files changed, 92 insertions(+), 123 deletions(-) diff --git a/doc/generic/pgf/CHANGELOG.md b/doc/generic/pgf/CHANGELOG.md index 40cb941b9..866d83705 100644 --- a/doc/generic/pgf/CHANGELOG.md +++ b/doc/generic/pgf/CHANGELOG.md @@ -18,7 +18,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Output bounding box adjustment in pgfsys-dvisvgm.def #1275 - Fix shadings under LuaMetaTeX - Resolve missing `gnuplot` plots in manual #1238 -- Fix missing inclusion of libraries in the examples at https://tikz.dev/gd-trees and https://tikz.dev/gd-usage-tikz +- Fix missing inclusion of libraries in the `graphdrawing` examples - Fix mis-spelled Kellermann to Kellerman ### Changed diff --git a/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/doc.lua b/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/doc.lua index 1bad4117f..52f8c4a05 100644 --- a/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/doc.lua +++ b/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/doc.lua @@ -98,58 +98,46 @@ sense that some nodes are ``nailed to the canvas'' while other nodes can ``move freely''. ]] -example({options = -[[ - preamble=\usetikzlibrary{graphs,graphdrawing} - \usegdlibrary{force} -]], -code = -[[ -\begin{tikzpicture} - \draw [help lines] (0,0) grid (3,2); - \graph [spring layout] - { - a[x=1] -- { b, c, d, e -- {f,g,h} }; - { h, g } -- a; - }; -\end{tikzpicture} -]] +example({ + options = [[ preamble=\usetikzlibrary{graphs,graphdrawing} \usegdlibrary{force} ]], + code = [[ + \begin{tikzpicture} + \draw [help lines] (0,0) grid (3,2); + \graph [spring layout] + { + a[x=1] -- { b, c, d, e -- {f,g,h} }; + { h, g } -- a; + }; + \end{tikzpicture} + ]] }) -example({options = -[[ - preamble=\usetikzlibrary{graphs,graphdrawing} - \usegdlibrary{force} -]], -code = -[[ -\begin{tikzpicture} - \draw [help lines] (0,0) grid (3,2); - \graph [spring layout] - { - a -- { b, c, d[x=0], e -- {f[x=2], g, h[x=1]} }; - { h, g } -- a; - }; -\end{tikzpicture} -]] +example({ + options = [[ preamble=\usetikzlibrary{graphs,graphdrawing} \usegdlibrary{force} ]], + code = [[ + \begin{tikzpicture} + \draw [help lines] (0,0) grid (3,2); + \graph [spring layout] + { + a -- { b, c, d[x=0], e -- {f[x=2], g, h[x=1]} }; + { h, g } -- a; + }; + \end{tikzpicture} + ]] }) -example({options = -[[ - preamble=\usetikzlibrary{graphs,graphdrawing} - \usegdlibrary{force} -]], -code = -[[ -\begin{tikzpicture} - \draw [help lines] (0,0) grid (3,2); - \graph [spring layout] - { - a -- { b, c, d[x=0], e -- {f[x=2,y=1], g, h[x=1]} }; - { h, g } -- a; - }; -\end{tikzpicture} -]] +example({ + options = [[ preamble=\usetikzlibrary{graphs,graphdrawing} \usegdlibrary{force} ]], + code = [[ + \begin{tikzpicture} + \draw [help lines] (0,0) grid (3,2); + \graph [spring layout] + { + a -- { b, c, d[x=0], e -- {f[x=2,y=1], g, h[x=1]} }; + { h, g } -- a; + }; + \end{tikzpicture} + ]] }) -------------------------------------------------------------------- @@ -180,34 +168,26 @@ Note how in the last example |c| is placed at |(1,1)| rather than |b| as would happen by default. ]] -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({ + 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({options = -[[ - preamble=\usetikzlibrary{graphs,graphdrawing} - \usegdlibrary{layered} -]], -code = -[[ -\begin{tikzpicture} - \draw [help lines] (0,0) grid (3,2); +example({ + options = [[ preamble=\usetikzlibrary{graphs,graphdrawing} \usegdlibrary{layered} ]], + code = [[ + \begin{tikzpicture} + \draw [help lines] (0,0) grid (3,2); - \graph [layered layout, anchor node=c, edges=rounded corners] - { a -- {b [x=1,y=1], c [x=1,y=1] } -- d -- a}; -\end{tikzpicture} -]] + \graph [layered layout, anchor node=c, edges=rounded corners] + { a -- {b [x=1,y=1], c [x=1,y=1] } -- d -- a}; + \end{tikzpicture} + ]] }) -------------------------------------------------------------------- @@ -223,20 +203,16 @@ 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({options = -[[ - preamble=\usetikzlibrary{graphs,graphdrawing} - \usegdlibrary{layered} -]], -code = -[[ -\begin{tikzpicture} - \draw [help lines] (0,0) grid (2,2); +example({ + options = [[ preamble=\usetikzlibrary{graphs,graphdrawing} \usegdlibrary{layered} ]], + code = [[ + \begin{tikzpicture} + \draw [help lines] (0,0) grid (2,2); - \graph [layered layout, edges=rounded corners, anchor at={(1,2)}] - { a -- {b, c [anchor here] } -- d -- a}; -\end{tikzpicture} -]] + \graph [layered layout, edges=rounded corners, anchor at={(1,2)}] + { a -- {b, c [anchor here] } -- d -- a}; + \end{tikzpicture} + ]] }) -------------------------------------------------------------------- @@ -259,19 +235,15 @@ In the example, |c| is placed at the origin since this is the default |anchor at| position. ]] -example({options = -[[ - preamble=\usetikzlibrary{graphs,graphdrawing} - \usegdlibrary{layered} -]], -code = -[[ -\begin{tikzpicture} - \draw [help lines] (0,0) grid (2,2); +example({ + options = [[ preamble=\usetikzlibrary{graphs,graphdrawing} \usegdlibrary{layered} ]], + code = [[ + \begin{tikzpicture} + \draw [help lines] (0,0) grid (2,2); - \graph [layered layout, edges=rounded corners] - { a -- {b, c [anchor here] } -- d -- a}; -\end{tikzpicture} -]] + \graph [layered layout, edges=rounded corners] + { a -- {b, c [anchor here] } -- d -- a}; + \end{tikzpicture} + ]] }) -------------------------------------------------------------------- diff --git a/tex/generic/pgf/graphdrawing/lua/pgf/gd/trees/doc.lua b/tex/generic/pgf/graphdrawing/lua/pgf/gd/trees/doc.lua index f8274b4da..6560caea6 100644 --- a/tex/generic/pgf/graphdrawing/lua/pgf/gd/trees/doc.lua +++ b/tex/generic/pgf/graphdrawing/lua/pgf/gd/trees/doc.lua @@ -293,29 +293,26 @@ example }; ]] -example({options = -[[ - preamble=\usetikzlibrary{shapes.misc, arrows.meta, decorations.pathmorphing} -]], -code = -[[ -\tikz \graph [binary tree layout] { - Knuth -> { - Beeton -> Kellerman [second] -> Carnes, - Tobin -> Plass -> { Lamport, Spivak } - } -};\qquad -\tikz [>={Stealth[round,sep]}] - \graph [binary tree layout, grow'=right, level sep=1.5em, - nodes={right, fill=blue!50, text=white, chamfered rectangle}, - edges={decorate,decoration={snake, post length=5pt}}] - { - Knuth -> { - Beeton -> Kellerman [second] -> Carnes, - Tobin -> Plass -> { Lamport, Spivak } - } - }; -]] +example({ + options = [[ preamble=\usetikzlibrary{shapes.misc, arrows.meta, decorations.pathmorphing} ]], + code = [[ + \tikz \graph [binary tree layout] { + Knuth -> { + Beeton -> Kellerman [second] -> Carnes, + Tobin -> Plass -> { Lamport, Spivak } + } + };\qquad + \tikz [>={Stealth[round,sep]}] + \graph [binary tree layout, grow'=right, level sep=1.5em, + nodes={right, fill=blue!50, text=white, chamfered rectangle}, + edges={decorate,decoration={snake, post length=5pt}}] + { + Knuth -> { + Beeton -> Kellerman [second] -> Carnes, + Tobin -> Plass -> { Lamport, Spivak } + } + }; + ]] }) --------------------------------------------------------------------