Skip to content

Commit 7ace0af

Browse files
committed
RF: use long_description for README.rst
Use script to synchronize README.rst with long description in info.py. Use long_description for inclusion in docs. This allows us to put extra github-related cruft at the top of the README.rst.
1 parent e8b36c4 commit 7ace0af

File tree

8 files changed

+48
-6
lines changed

8 files changed

+48
-6
lines changed

Makefile

+3
Original file line numberDiff line numberDiff line change
@@ -281,5 +281,8 @@ tox-stale:
281281
# installed)
282282
tox -e python25,python26,python27,python32,np-1.2.1
283283

284+
refresh-readme:
285+
$(PYTHON) tools/refresh_readme.py
286+
284287
.PHONY: orig-src pylint
285288

README.rst

+3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
.. -*- rest -*-
22
.. vim:syntax=rest
33
4+
.. Following contents should be from LONG_DESCRIPTION in nibabel/info.py
5+
6+
47
=======
58
NiBabel
69
=======

doc/source/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
_long_description.inc

doc/source/conf.py

+4
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@
3434
rel = {}
3535
execfile('../../nibabel/info.py', rel)
3636

37+
# Write long description from info
38+
with open('_long_description.inc', 'wt') as fobj:
39+
fobj.write(rel['LONG_DESCRIPTION'])
40+
3741
# Add any Sphinx extension module names here, as strings. They can be extensions
3842
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
3943
extensions = ['sphinx.ext.autodoc',

doc/source/devel/make_release.rst

+4-2
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,10 @@ Release checklist
6464

6565
* Check the copyright year in ``doc/source/conf.py``
6666

67-
* Check the ``long_description`` in ``nibabel/info.py``. Check it matches the
68-
``README`` in the root directory. Check the output of::
67+
* Refresh the ``REAMDE.rst`` text from the ``LONG_DESCRIPTION`` in ``info.py``
68+
by running ``make refresh_readme``.
69+
70+
Check the output of::
6971

7072
rst2html.py README.rst > ~/tmp/readme.html
7173

doc/source/index.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#
88
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ###
99
10-
.. include:: ../../README.rst
10+
.. include:: _long_description.inc
1111

1212
Documentation
1313
=============

nibabel/info.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,11 @@
2828

2929
description = 'Access a multitude of neuroimaging data formats'
3030

31-
# Note: this long_description is actually a copy/paste from the top-level
32-
# README.rst, so that it shows up nicely on PyPI. So please remember to edit
33-
# it only in one place and sync it correctly.
31+
# Note: this long_description is the canonical place to edit this text.
32+
# It also appears in README.rst, but it should get there by running
33+
# ``tools/refresh_readme.py`` which pulls in this version.
34+
# We also include this text in the docs by ``..include::`` in
35+
# ``docs/source/index.rst``.
3436
long_description = """
3537
=======
3638
NiBabel

tools/refresh_readme.py

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env python
2+
""" Refresh README.rst file from long description
3+
4+
Should be run from nibabel root (containing setup.py)
5+
"""
6+
from __future__ import print_function
7+
8+
import os
9+
10+
readme_lines = []
11+
with open('README.rst', 'rt') as fobj:
12+
for line in fobj:
13+
readme_lines.append(line)
14+
if line.startswith('.. Following contents should be'):
15+
break
16+
else:
17+
raise ValueError('Expected comment not found')
18+
19+
rel = {}
20+
execfile(os.path.join('nibabel', 'info.py'), rel)
21+
22+
readme = ''.join(readme_lines) + '\n' + rel['LONG_DESCRIPTION']
23+
24+
with open('README.rst', 'wt') as fobj:
25+
fobj.write(readme)
26+
27+
print('Done')

0 commit comments

Comments
 (0)