Skip to content

Commit

Permalink
doc: generate man pages in man/Makefile
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
tchaikov committed Mar 24, 2015
1 parent 8dd9f6a commit 301fe6c
Show file tree
Hide file tree
Showing 37 changed files with 64 additions and 37 deletions.
1 change: 1 addition & 0 deletions ceph.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ BuildRequires: python
BuildRequires: python-argparse
BuildRequires: python-nose
BuildRequires: python-requests
BuildRequires: python-sphinx
BuildRequires: python-virtualenv
BuildRequires: util-linux
BuildRequires: xfsprogs
Expand Down
5 changes: 5 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ if test -d ".git" ; then
fi
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_SUBDIRS([src/gmock])
Expand Down
1 change: 1 addition & 0 deletions debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ Build-Depends: autoconf,
python (>= 2.6.6-3~),
python-argparse,
python-nose,
python-sphinx,
python-virtualenv,
sdparm | hdparm,
uuid-dev,
Expand Down
37 changes: 0 additions & 37 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,43 +32,6 @@
]
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(
os.path.dirname(
os.path.abspath(__file__)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
15 changes: 15 additions & 0 deletions man/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,18 @@ endif
if ENABLE_SERVER
include Makefile-server.am
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 changes: 42 additions & 0 deletions man/conf.py
Original file line number Diff line number Diff line change
@@ -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())

0 comments on commit 301fe6c

Please sign in to comment.