Skip to content

Commit

Permalink
Generate and use version.py for Sphinx
Browse files Browse the repository at this point in the history
Sphinx's idea of the version number appears in the man pages and
compiled PDF documents, and shows up as metadata in the generated
HTML sources.

Extract the version information from the master source (patchlevel.h)
into a form usable by Sphinx.

(cherry picked from commit 07c77b5)

ticket: 7433
  • Loading branch information
tlyu committed Nov 16, 2012
1 parent 60f4c14 commit 8d290c2
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ obj/
testdir/
testlog

/doc/version.py

/doc/html/

/src/config.log
Expand Down
11 changes: 8 additions & 3 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,16 @@
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
execfile("version.py")
# The short X.Y version.
version = '0.0.1'
r_list = [r_major, r_minor]
if r_patch:
r_list += [r_patch]
version = '.'.join(map(str, r_list))
# The full version, including alpha/beta/rc tags.
release = '0.0.1'
release = version
if r_tail:
release += '-' + r_tail

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
15 changes: 12 additions & 3 deletions src/doc/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ NOTICE: notice.txt
# Use doxygen to generate API documentation, translate it into RST
# format, and then create a composite of $(docsrc)'s RST and the
# generated files in rst_composite. Used by the html and substhtml targets.
composite: Doxyfile
composite: Doxyfile $(docsrc)/version.py
rm -rf doxy rst_apiref rst_composite
$(DOXYGEN)
cwd=`pwd`; cd $(docsrc)/tools && \
Expand All @@ -70,15 +70,17 @@ composite: Doxyfile
cp rst_apiref/*.rst rst_composite/appldev/refs/api
cp rst_apiref/types/*.rst rst_composite/appldev/refs/types
cp rst_apiref/macros/*.rst rst_composite/appldev/refs/macros
cp $(docsrc)/version.py rst_composite

# Must use a separate source dir for sphinx text builds, since the text
# engine cannot handle the row spanning cells in fancy tables that we use
rst_notice: $(docsrc)/notice.rst $(docsrc)/txt_conf.py
rst_notice: $(docsrc)/notice.rst $(docsrc)/txt_conf.py $(docsrc)/version.py
mkdir -p rst_notice
# reST needs backslashes before parens in this macro definition.
sed -e 's/include:: <isonum.txt>/|copy| replace:: \\(C\\)/' \
< $(docsrc)/notice.rst > rst_notice/notice.rst
cp $(docsrc)/txt_conf.py rst_notice/conf.py
cp $(docsrc)/version.py rst_notice

Doxyfile: $(srcdir)/Doxyfile.in
sed -e 's|@SRC@|$(top_srcdir)|g' \
Expand All @@ -95,6 +97,13 @@ paths.py:
echo 'keytab = "``$(DEFKTNAME)``"' >> $@
echo 'ckeytab = "``$(DEFCKTNAME)``"' >> $@

# Dummy rule that man/Makefile can invoke
version.py: $(docsrc)/version.py

$(docsrc)/version.py: $(top_srcdir)/patchlevel.h $(srcdir)/version.py.in
$(RM) $@
$(CC) -E -I$(top_srcdir) - < $(srcdir)/version.py.in > $@

clean::
rm -rf doxy rst_apiref rst_composite rst_notice html_subst \
Doxyfile paths.py
Doxyfile paths.py $(docsrc)/version.py
21 changes: 21 additions & 0 deletions src/doc/version.py.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include "patchlevel.h"

r_major = KRB5_MAJOR_RELEASE
r_minor = KRB5_MINOR_RELEASE
r_patch = KRB5_PATCHLEVEL

#ifdef KRB5_RELTAIL
r_tail = KRB5_RELTAIL
#else
r_tail = None
#endif
#ifdef KRB5_RELDATE
r_date = KRB5_RELDATE
#else
r_date = None
#endif
#ifdef KRB5_RELTAG
r_tag = KRB5_RELTAG
#else
r_date = None
#endif
5 changes: 4 additions & 1 deletion src/man/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,17 @@ docsrc=$(top_srcdir)/../doc
# make -f Makefile.in clean
# The sed command deletes some trailing whitespace that the docutils
# manpage writer outputs near the end of its output files.
man:
man: $(docsrc)/version.py
rm -rf rst_man
$(SPHINX_BUILD) -q -t mansubs -b man $(docsrc) rst_man
for f in rst_man/*.[0-9]; do \
name=`echo $$f | sed -e 's|^.*/\(.*\)\.[0-9]$$|\1|'`; \
sed -e '/^\.\\" $$/d' $$f > $(srcdir)/$$name.man; \
done

$(docsrc)/version.py: $(top_srcdir)/patchlevel.h
(cd $(BUILDTOP)/doc && make version.py)

.SUFFIXES: .man .sub

.man.sub:
Expand Down

0 comments on commit 8d290c2

Please sign in to comment.