Skip to content

Commit 0c8e059

Browse files
committed
Additional changes in response to the feedback at
pgf-tikz#1335 Signed-off-by: Hanson Char <hanson.char@gmail.com>
1 parent 5f1f861 commit 0c8e059

File tree

3 files changed

+58
-23
lines changed

3 files changed

+58
-23
lines changed

tex/generic/pgf/graphdrawing/lua/pgf/gd/control/doc.lua

Lines changed: 49 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,12 @@ sense that some nodes are ``nailed to the canvas'' while other
9898
nodes can ``move freely''.
9999
]]
100100

101-
--[[
102-
% TODOsp: codeexamples: the following 3 examples need these libraries
103-
% \usetikzlibrary{graphs,graphdrawing}
104-
% \usegdlibrary{force}
105-
--]]
106-
example
101+
example({options =
102+
[[
103+
preamble=\usetikzlibrary{graphs,graphdrawing}
104+
\usegdlibrary{force}
105+
]],
106+
code =
107107
[[
108108
\begin{tikzpicture}
109109
\draw [help lines] (0,0) grid (3,2);
@@ -114,8 +114,14 @@ example
114114
};
115115
\end{tikzpicture}
116116
]]
117+
})
117118

118-
example
119+
example({options =
120+
[[
121+
preamble=\usetikzlibrary{graphs,graphdrawing}
122+
\usegdlibrary{force}
123+
]],
124+
code =
119125
[[
120126
\begin{tikzpicture}
121127
\draw [help lines] (0,0) grid (3,2);
@@ -126,8 +132,14 @@ example
126132
};
127133
\end{tikzpicture}
128134
]]
135+
})
129136

130-
example
137+
example({options =
138+
[[
139+
preamble=\usetikzlibrary{graphs,graphdrawing}
140+
\usegdlibrary{force}
141+
]],
142+
code =
131143
[[
132144
\begin{tikzpicture}
133145
\draw [help lines] (0,0) grid (3,2);
@@ -138,6 +150,7 @@ example
138150
};
139151
\end{tikzpicture}
140152
]]
153+
})
141154
--------------------------------------------------------------------
142155

143156

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

170-
--[[
171-
% TODOsp: codeexamples: the following 4 examples need these libraries
172-
% \usetikzlibrary{graphs,graphdrawing}
173-
% \usegdlibrary{layered}
174-
--]]
175-
example
183+
example({options =
184+
[[
185+
preamble=\usetikzlibrary{graphs,graphdrawing}
186+
\usegdlibrary{layered}
187+
]],
188+
code =
176189
[[
177190
\tikz \draw (0,0)
178191
-- (1,0.5) graph [edges=red, layered layout, anchor node=a] { a -> {b,c} }
179192
-- (1.5,0) graph [edges=blue, layered layout,
180193
anchor node=y, anchor at={(2,0)}] { x -> {y,z} };
181194
]]
195+
})
182196

183-
example
197+
example({options =
198+
[[
199+
preamble=\usetikzlibrary{graphs,graphdrawing}
200+
\usegdlibrary{layered}
201+
]],
202+
code =
184203
[[
185204
\begin{tikzpicture}
186205
\draw [help lines] (0,0) grid (3,2);
@@ -189,6 +208,7 @@ example
189208
{ a -- {b [x=1,y=1], c [x=1,y=1] } -- d -- a};
190209
\end{tikzpicture}
191210
]]
211+
})
192212
--------------------------------------------------------------------
193213

194214

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

206-
example
226+
example({options =
227+
[[
228+
preamble=\usetikzlibrary{graphs,graphdrawing}
229+
\usegdlibrary{layered}
230+
]],
231+
code =
207232
[[
208233
\begin{tikzpicture}
209234
\draw [help lines] (0,0) grid (2,2);
@@ -212,6 +237,7 @@ example
212237
{ a -- {b, c [anchor here] } -- d -- a};
213238
\end{tikzpicture}
214239
]]
240+
})
215241
--------------------------------------------------------------------
216242

217243

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

236-
example
262+
example({options =
263+
[[
264+
preamble=\usetikzlibrary{graphs,graphdrawing}
265+
\usegdlibrary{layered}
266+
]],
267+
code =
237268
[[
238269
\begin{tikzpicture}
239270
\draw [help lines] (0,0) grid (2,2);
@@ -242,4 +273,5 @@ example
242273
{ a -- {b, c [anchor here] } -- d -- a};
243274
\end{tikzpicture}
244275
]]
276+
})
245277
--------------------------------------------------------------------

tex/generic/pgf/graphdrawing/lua/pgf/gd/doc.lua

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,10 @@ end
112112
-- Adds an example to the |examples| field of the last key selected
113113
-- through the |key| command.
114114
--
115-
-- @param string An additional example string.
116-
117-
function doc.example (string)
115+
-- @param input either a string of example or a table with two fields - "code" and "options".
116+
function doc.example (input)
118117
local examples = rawget(current_key, "examples") or {}
119-
examples[#examples + 1] = string
118+
examples[#examples + 1] = input
120119
current_key.examples = examples
121120
end
122121

tex/generic/pgf/graphdrawing/lua/pgf/gd/trees/doc.lua

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,9 +293,12 @@ example
293293
};
294294
]]
295295

296-
example
296+
example({options =
297+
[[
298+
preamble=\usetikzlibrary{shapes.misc, arrows.meta, decorations.pathmorphing}
299+
]],
300+
code =
297301
[[
298-
\usetikzlibrary{shapes.misc, arrows.meta, decorations.pathmorphing}
299302
\tikz \graph [binary tree layout] {
300303
Knuth -> {
301304
Beeton -> Kellermann [second] -> Carnes,
@@ -313,6 +316,7 @@ example
313316
}
314317
};
315318
]]
319+
})
316320
--------------------------------------------------------------------
317321

318322

0 commit comments

Comments
 (0)