Skip to content

Commit

Permalink
Merge branch 'ps/build-meson-html'
Browse files Browse the repository at this point in the history
The build procedure based on meson learned to generate HTML
documention pages.

* ps/build-meson-html:
  Documentation: wire up sanity checks for Meson
  t/Makefile: make "check-meson" work with Dash
  meson: install static files for HTML documentation
  meson: generate articles
  Documentation: refactor "howto-index.sh" for out-of-tree builds
  Documentation: refactor "api-index.sh" for out-of-tree builds
  meson: generate user manual
  Documentation: inline user-manual.conf
  meson: generate HTML pages for all man page categories
  meson: fix generation of merge tools
  meson: properly wire up dependencies for our docs
  meson: wire up support for AsciiDoctor
  • Loading branch information
gitster committed Jan 2, 2025
2 parents effbef2 + 5419445 commit 1b4e9a5
Show file tree
Hide file tree
Showing 12 changed files with 402 additions and 63 deletions.
1 change: 1 addition & 0 deletions Documentation/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ cmds-*.txt
mergetools-*.txt
SubmittingPatches.txt
tmp-doc-diff/
tmp-meson-diff/
GIT-ASCIIDOCFLAGS
/.build/
/GIT-EXCLUDED-PROGRAMS
Expand Down
24 changes: 20 additions & 4 deletions Documentation/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@ clean:
$(RM) $(cmds_txt) $(mergetools_txt) *.made
$(RM) GIT-ASCIIDOCFLAGS
$(RM) asciidoc.conf asciidoctor-extensions.rb
$(RM) -rf tmp-meson-diff

docinfo.html: docinfo-html.in
$(QUIET_GEN)$(RM) $@ && cat $< >$@
Expand All @@ -362,12 +363,12 @@ manpage-cmd = $(QUIET_XMLTO)$(XMLTO) -m $(MANPAGE_XSL) $(XMLTO_EXTRA) man $<
%.xml : %.txt $(ASCIIDOC_DEPS)
$(QUIET_ASCIIDOC)$(TXT_TO_XML) -d manpage -o $@ $<

user-manual.xml: user-manual.txt user-manual.conf $(ASCIIDOC_DEPS)
user-manual.xml: user-manual.txt $(ASCIIDOC_DEPS)
$(QUIET_ASCIIDOC)$(TXT_TO_XML) -d book -o $@ $<

technical/api-index.txt: technical/api-index-skel.txt \
technical/api-index.sh $(patsubst %,%.txt,$(API_DOCS))
$(QUIET_GEN)cd technical && '$(SHELL_PATH_SQ)' ./api-index.sh
$(QUIET_GEN)'$(SHELL_PATH_SQ)' technical/api-index.sh ./technical ./technical/api-index.txt

technical/%.html: ASCIIDOC_EXTRA += -a git-relative-html-prefix=../
$(patsubst %,%.html,$(API_DOCS) technical/api-index $(TECH_DOCS)): %.html : %.txt \
Expand Down Expand Up @@ -411,8 +412,8 @@ gitman.info: gitman.texi
$(patsubst %.txt,%.texi,$(MAN_TXT)): %.texi : %.xml
$(QUIET_DB2TEXI)$(DOCBOOK2X_TEXI) --to-stdout $*.xml >$@

howto-index.txt: howto-index.sh $(HOWTO_TXT)
$(QUIET_GEN)'$(SHELL_PATH_SQ)' ./howto-index.sh $(sort $(HOWTO_TXT)) >$@
howto-index.txt: howto/howto-index.sh $(HOWTO_TXT)
$(QUIET_GEN)'$(SHELL_PATH_SQ)' ./howto/howto-index.sh $(sort $(HOWTO_TXT)) >$@

$(patsubst %,%.html,$(ARTICLES)) : %.html : %.txt $(ASCIIDOC_DEPS)
$(QUIET_ASCIIDOC)$(TXT_TO_HTML) $*.txt
Expand Down Expand Up @@ -494,13 +495,28 @@ lint-docs-fsck-msgids: $(LINT_DOCS_FSCK_MSGIDS)
lint-docs-manpages:
$(QUIET_GEN)./lint-manpages.sh

.PHONY: lint-docs-meson
lint-docs-meson:
@# awk acts up when trying to match single quotes, so we use \047 instead.
@mkdir -p tmp-meson-diff && \
awk "/^manpages = {$$/ {flag=1 ; next } /^}$$/ { flag=0 } flag { gsub(/^ \047/, \"\"); gsub(/\047 : [157],\$$/, \"\"); print }" meson.build | \
grep -v -e '#' -e '^$$' | \
sort >tmp-meson-diff/meson.txt && \
ls git*.txt scalar.txt | grep -v -e git-bisect-lk2009.txt -e git-tools.txt >tmp-meson-diff/actual.txt && \
if ! cmp tmp-meson-diff/meson.txt tmp-meson-diff/actual.txt; then \
echo "Meson man pages differ from actual man pages:"; \
diff -u tmp-meson-diff/meson.txt tmp-meson-diff/actual.txt; \
exit 1; \
fi

## Lint: list of targets above
.PHONY: lint-docs
lint-docs: lint-docs-fsck-msgids
lint-docs: lint-docs-gitlink
lint-docs: lint-docs-man-end-blurb
lint-docs: lint-docs-man-section-order
lint-docs: lint-docs-manpages
lint-docs: lint-docs-meson

ifeq ($(wildcard po/Makefile),po/Makefile)
doc-l10n install-l10n::
Expand Down
10 changes: 10 additions & 0 deletions Documentation/asciidoc.conf.in
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,22 @@ manmanual=Git Manual
mansource=Git @GIT_VERSION@
revdate=@GIT_DATE@

ifdef::doctype-book[]
[titles]
underlines="__","==","--","~~","^^"
endif::doctype-book[]

ifdef::backend-docbook[]
[linkgit-inlinemacro]
ifndef::doctype-book[]
{0%{target}}
{0#<citerefentry>}
{0#<refentrytitle>{target}</refentrytitle><manvolnum>{0}</manvolnum>}
{0#</citerefentry>}
endif::doctype-book[]
ifdef::doctype-book[]
<ulink url="{target}.html">{target}{0?({0})}</ulink>
endif::doctype-book[]

[literal-inlinemacro]
{eval:re.sub(r'(&lt;[-a-zA-Z0-9.]+&gt;)', r'<emphasis>\1</emphasis>', re.sub(r'([\[\s|()>]|^|\]|&gt;)(\.?([-a-zA-Z0-9:+=~@,\/_^\$]+\.?)+)',r'\1<literal>\2</literal>', re.sub(r'(\.\.\.?)([^\]$.])', r'<literal>\1</literal>\2', macros.passthroughs[int(attrs['passtext'][1:-1])] if attrs['passtext'][1:-1].isnumeric() else attrs['passtext'][1:-1])))}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ do
file="$txt"
fi

echo "* link:$file[$title] $from
echo "* link:howto/$(basename "$file")[$title] $from
$abstract
"
Expand Down
62 changes: 62 additions & 0 deletions Documentation/howto/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
howto_sources = [
'coordinate-embargoed-releases.txt',
'keep-canonical-history-correct.txt',
'maintain-git.txt',
'new-command.txt',
'rebase-from-internal-branch.txt',
'rebuild-from-update-hook.txt',
'recover-corrupted-blob-object.txt',
'recover-corrupted-object-harder.txt',
'revert-a-faulty-merge.txt',
'revert-branch-rebase.txt',
'separating-topic-branches.txt',
'setup-git-server-over-http.txt',
'update-hook-example.txt',
'use-git-daemon.txt',
'using-merge-subtree.txt',
'using-signed-tag-in-pull-request.txt',
]

howto_index = custom_target(
command: [
shell,
meson.current_source_dir() / 'howto-index.sh',
'@INPUT@',
],
env: script_environment,
capture: true,
input: howto_sources,
output: 'howto-index.txt',
)

custom_target(
command: asciidoc_html_options,
input: howto_index,
output: 'howto-index.html',
depends: documentation_deps,
install: true,
install_dir: get_option('datadir') / 'doc/git-doc',
)

foreach howto : howto_sources
howto_stripped = custom_target(
command: [
find_program('sed'),
'-e',
'1,/^$/d',
'@INPUT@',
],
input: howto,
output: fs.stem(howto) + '.stripped',
capture: true,
)

custom_target(
command: asciidoc_html_options,
input: howto_stripped,
output: fs.stem(howto_stripped.full_path()) + '.html',
depends: documentation_deps,
install: true,
install_dir: get_option('datadir') / 'doc/git-doc/howto',
)
endforeach
Loading

0 comments on commit 1b4e9a5

Please sign in to comment.