doc: generate man pages in man/Makefile

* move rst files from doc/man/8 into man/8
* extract man_pages setting for sphinx from doc/conf.py to man/conf.py
* generate all man pages in `make install`
* add python-sphinx to Build-Depends
* check for sphinx-build in `configure`
* run changed rst files through sphinx-build in `make check`

Signed-off-by: Kefu Chai <kchai@redhat.com>
This commit is contained in:
Kefu Chai 2015-03-23 14:08:16 +08:00
parent 8dd9f6a4ed
commit 301fe6cbf2
37 changed files with 64 additions and 37 deletions

View File

@ -60,6 +60,7 @@ BuildRequires: python
BuildRequires: python-argparse BuildRequires: python-argparse
BuildRequires: python-nose BuildRequires: python-nose
BuildRequires: python-requests BuildRequires: python-requests
BuildRequires: python-sphinx
BuildRequires: python-virtualenv BuildRequires: python-virtualenv
BuildRequires: util-linux BuildRequires: util-linux
BuildRequires: xfsprogs BuildRequires: xfsprogs

View File

@ -21,6 +21,11 @@ if test -d ".git" ; then
fi fi
AC_MSG_NOTICE([RPM_RELEASE='$RPM_RELEASE']) AC_MSG_NOTICE([RPM_RELEASE='$RPM_RELEASE'])
AC_CHECK_PROG(SPHINX_BUILD, sphinx-build, yes, no)
if test x"$SPHINX_BUILD" = x"no"; then
AC_MSG_ERROR([sphinx-build not found (python-sphinx)])
fi
AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_SUBDIRS([src/gmock]) AC_CONFIG_SUBDIRS([src/gmock])

1
debian/control vendored
View File

@ -46,6 +46,7 @@ Build-Depends: autoconf,
python (>= 2.6.6-3~), python (>= 2.6.6-3~),
python-argparse, python-argparse,
python-nose, python-nose,
python-sphinx,
python-virtualenv, python-virtualenv,
sdparm | hdparm, sdparm | hdparm,
uuid-dev, uuid-dev,

View File

@ -32,43 +32,6 @@ extensions = [
] ]
todo_include_todos = True todo_include_todos = True
def _get_manpages():
import os
man_dir = os.path.join(
os.path.dirname(__file__),
'man',
)
sections = os.listdir(man_dir)
for section in sections:
section_dir = os.path.join(man_dir, section)
if not os.path.isdir(section_dir):
continue
for filename in os.listdir(section_dir):
base, ext = os.path.splitext(filename)
if ext != '.rst':
continue
if base == 'index':
continue
with file(os.path.join(section_dir, filename)) as f:
one = f.readline()
two = f.readline()
three = f.readline()
assert one == three
assert all(c=='=' for c in one.rstrip('\n'))
two = two.strip()
name, rest = two.split('--', 1)
assert name.strip() == base
description = rest.strip()
yield (
os.path.join('man', section, base),
base,
description,
'',
section,
)
man_pages = list(_get_manpages())
top_level = os.path.dirname( top_level = os.path.dirname(
os.path.dirname( os.path.dirname(
os.path.abspath(__file__) os.path.abspath(__file__)

View File

@ -9,3 +9,18 @@ endif
if ENABLE_SERVER if ENABLE_SERVER
include Makefile-server.am include Makefile-server.am
endif endif
check-local:
sphinx-build -b man -d doctrees . $(top_builddir)/man
# prevent `make` from running in parallel, sphinx runs better in batch mode.
.PHONY: sphinx-build.stamp
$(dist_man_MANS): sphinx-build.stamp
sphinx-build.stamp:
sphinx-build -Q -b man -d doctrees -c . . $(top_builddir)/man
clean-local:
@rm -f *.8
@rm -rf doctrees

42
man/conf.py Normal file
View File

@ -0,0 +1,42 @@
import os
project = u'Ceph'
copyright = u'2010-2014, Inktank Storage, Inc. and contributors. Licensed under Creative Commons BY-SA'
version = 'dev'
release = 'dev'
exclude_patterns = ['**/.#*', '**/*~']
def _get_manpages():
import os
man_dir = os.path.dirname(__file__)
sections = os.listdir(man_dir)
for section in sections:
section_dir = os.path.join(man_dir, section)
if not os.path.isdir(section_dir):
continue
for filename in os.listdir(section_dir):
base, ext = os.path.splitext(filename)
if ext != '.rst':
continue
if base == 'index':
continue
with file(os.path.join(section_dir, filename)) as f:
one = f.readline()
two = f.readline()
three = f.readline()
assert one == three
assert all(c=='=' for c in one.rstrip('\n'))
two = two.strip()
name, rest = two.split('--', 1)
assert name.strip() == base
description = rest.strip()
yield (
os.path.join(section, base),
base,
description,
'',
section,
)
man_pages = list(_get_manpages())