Skip to content

Commit 9219325

Browse files
pks-tgitster
authored andcommitted
Documentation: allow sourcing generated includes from separate dir
Our documentation uses "include::" directives to include parts that are either reused across multiple documents or parts that we generate at build time. Unfortunately, top-level includes are only ever resolved relative to the base directory, which is typically the directory of the including document. Most importantly, it is not possible to have either asciidoc or asciidoctor search multiple directories. It follows that both kinds of includes must live in the same directory. This is of course a bummer for out-of-tree builds, because here the dynamically-built includes live in the build directory whereas the static includes live in the source directory. Introduce a `build_dir` attribute and prepend it to all of our includes for dynamically-built files. This attribute gets set to the build directory and thus converts the include path to an absolute path, which asciidoc and asciidoctor know how to resolve. Note that this change also requires us to update "build-docdep.perl", which tries to figure out included files such our Makefile can set up proper build-time dependencies. This script simply scans through the source files for any lines that match "^include::" and treats the remainder of the line as included file path. But given that those may now contain the "{build_dir}" variable we have to teach the script to replace that attribute with the actual build directory. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ed060aa commit 9219325

File tree

5 files changed

+18
-15
lines changed

5 files changed

+18
-15
lines changed

Documentation/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ SHELL_PATH ?= $(SHELL)
224224
# Shell quote;
225225
SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
226226

227+
ASCIIDOC_EXTRA += -abuild_dir='$(shell pwd)'
227228
ifdef DEFAULT_PAGER
228229
DEFAULT_PAGER_SQ = $(subst ','\'',$(DEFAULT_PAGER))
229230
ASCIIDOC_EXTRA += -a 'git-default-pager=$(DEFAULT_PAGER_SQ)'
@@ -289,7 +290,7 @@ docdep_prereqs = \
289290
cmd-list.made $(cmds_txt)
290291

291292
doc.dep : $(docdep_prereqs) $(DOC_DEP_TXT) build-docdep.perl
292-
$(QUIET_GEN)$(PERL_PATH) ./build-docdep.perl >$@ $(QUIET_STDERR)
293+
$(QUIET_GEN)$(PERL_PATH) ./build-docdep.perl "$(shell pwd)" >$@ $(QUIET_STDERR)
293294

294295
ifneq ($(MAKECMDGOALS),clean)
295296
-include doc.dep

Documentation/build-docdep.perl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/usr/bin/perl
22

3+
my ($build_dir) = @ARGV;
34
my %include = ();
45
my %included = ();
56

@@ -10,6 +11,7 @@
1011
chomp;
1112
s/^include::\s*//;
1213
s/\[\]//;
14+
s/{build_dir}/${build_dir}/;
1315
$include{$text}{$_} = 1;
1416
$included{$_} = 1;
1517
}

Documentation/config/diff.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ endif::git-diff[]
218218
Set this option to `true` to make the diff driver cache the text
219219
conversion outputs. See linkgit:gitattributes[5] for details.
220220

221-
include::../mergetools-diff.txt[]
221+
include::{build_dir}/mergetools-diff.txt[]
222222

223223
`diff.indentHeuristic`::
224224
Set this option to `false` to disable the default heuristics

Documentation/config/merge.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ merge.guitool::
101101
Any other value is treated as a custom merge tool and requires that a
102102
corresponding mergetool.<guitool>.cmd variable is defined.
103103

104-
include::../mergetools-merge.txt[]
104+
include::{build_dir}/mergetools-merge.txt[]
105105

106106
merge.verbosity::
107107
Controls the amount of output shown by the recursive merge

Documentation/git.txt

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -245,17 +245,17 @@ ancillary user utilities.
245245
Main porcelain commands
246246
~~~~~~~~~~~~~~~~~~~~~~~
247247

248-
include::cmds-mainporcelain.txt[]
248+
include::{build_dir}/cmds-mainporcelain.txt[]
249249

250250
Ancillary Commands
251251
~~~~~~~~~~~~~~~~~~
252252
Manipulators:
253253

254-
include::cmds-ancillarymanipulators.txt[]
254+
include::{build_dir}/cmds-ancillarymanipulators.txt[]
255255

256256
Interrogators:
257257

258-
include::cmds-ancillaryinterrogators.txt[]
258+
include::{build_dir}/cmds-ancillaryinterrogators.txt[]
259259

260260

261261
Interacting with Others
@@ -264,7 +264,7 @@ Interacting with Others
264264
These commands are to interact with foreign SCM and with other
265265
people via patch over e-mail.
266266

267-
include::cmds-foreignscminterface.txt[]
267+
include::{build_dir}/cmds-foreignscminterface.txt[]
268268

269269
Reset, restore and revert
270270
~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -313,13 +313,13 @@ repositories.
313313
Manipulation commands
314314
~~~~~~~~~~~~~~~~~~~~~
315315

316-
include::cmds-plumbingmanipulators.txt[]
316+
include::{build_dir}/cmds-plumbingmanipulators.txt[]
317317

318318

319319
Interrogation commands
320320
~~~~~~~~~~~~~~~~~~~~~~
321321

322-
include::cmds-plumbinginterrogators.txt[]
322+
include::{build_dir}/cmds-plumbinginterrogators.txt[]
323323

324324
In general, the interrogate commands do not touch the files in
325325
the working tree.
@@ -328,12 +328,12 @@ the working tree.
328328
Syncing repositories
329329
~~~~~~~~~~~~~~~~~~~~
330330

331-
include::cmds-synchingrepositories.txt[]
331+
include::{build_dir}/cmds-synchingrepositories.txt[]
332332

333333
The following are helper commands used by the above; end users
334334
typically do not use them directly.
335335

336-
include::cmds-synchelpers.txt[]
336+
include::{build_dir}/cmds-synchelpers.txt[]
337337

338338

339339
Internal helper commands
@@ -342,14 +342,14 @@ Internal helper commands
342342
These are internal helper commands used by other commands; end
343343
users typically do not use them directly.
344344

345-
include::cmds-purehelpers.txt[]
345+
include::{build_dir}/cmds-purehelpers.txt[]
346346

347347
Guides
348348
------
349349

350350
The following documentation pages are guides about Git concepts.
351351

352-
include::cmds-guide.txt[]
352+
include::{build_dir}/cmds-guide.txt[]
353353

354354
Repository, command and file interfaces
355355
---------------------------------------
@@ -358,7 +358,7 @@ This documentation discusses repository and command interfaces which
358358
users are expected to interact with directly. See `--user-formats` in
359359
linkgit:git-help[1] for more details on the criteria.
360360

361-
include::cmds-userinterfaces.txt[]
361+
include::{build_dir}/cmds-userinterfaces.txt[]
362362

363363
File formats, protocols and other developer interfaces
364364
------------------------------------------------------
@@ -367,7 +367,7 @@ This documentation discusses file formats, over-the-wire protocols and
367367
other git developer interfaces. See `--developer-interfaces` in
368368
linkgit:git-help[1].
369369

370-
include::cmds-developerinterfaces.txt[]
370+
include::{build_dir}/cmds-developerinterfaces.txt[]
371371

372372
Configuration Mechanism
373373
-----------------------

0 commit comments

Comments
 (0)