mirror of
https://github.com/psycopg/psycopg2.git
synced 2024-11-10 19:16:34 +03:00
Generate text documentation in a single file.
This commit is contained in:
parent
a1fa06e6d8
commit
620f77cb77
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -8,3 +8,4 @@ dist/*
|
|||
build/*
|
||||
doc/_build/*
|
||||
doc/html/*
|
||||
doc/psycopg2.txt
|
||||
|
|
|
@ -17,7 +17,7 @@ ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
|
|||
|
||||
.PHONY: help clean html dirhtml pickle json htmlhelp qthelp latex changes linkcheck doctest
|
||||
|
||||
doc: html
|
||||
all: html text
|
||||
|
||||
check: doctest
|
||||
|
||||
|
@ -48,6 +48,12 @@ dirhtml:
|
|||
@echo
|
||||
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
|
||||
|
||||
text:
|
||||
$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
|
||||
tools/stitch_text.py index.rst $(BUILDDIR)/text > psycopg2.txt
|
||||
@echo
|
||||
@echo "Build finished. The text file is psycopg2.txt."
|
||||
|
||||
pickle:
|
||||
$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
|
||||
@echo
|
||||
|
|
|
@ -40,6 +40,15 @@ Contents:
|
|||
extras
|
||||
errorcodes
|
||||
|
||||
|
||||
.. ifconfig:: builder != 'text'
|
||||
|
||||
.. rubric:: Indices and tables
|
||||
|
||||
* :ref:`genindex`
|
||||
* :ref:`search`
|
||||
|
||||
|
||||
.. ifconfig:: todo_include_todos
|
||||
|
||||
.. note::
|
||||
|
@ -48,11 +57,3 @@ Contents:
|
|||
|
||||
.. todolist::
|
||||
|
||||
|
||||
Indices and tables
|
||||
==================
|
||||
|
||||
* :ref:`genindex`
|
||||
* :ref:`search`
|
||||
|
||||
|
||||
|
|
56
doc/tools/stitch_text.py
Executable file
56
doc/tools/stitch_text.py
Executable file
|
@ -0,0 +1,56 @@
|
|||
#! /usr/bin/env python
|
||||
"""A script to stitch together the generated text files in the correct order.
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
def main():
|
||||
if len(sys.argv) != 3:
|
||||
print >>sys.stderr, "usage: %s index.rst text-dir"
|
||||
return 2
|
||||
|
||||
_, index, txt_dir = sys.argv
|
||||
|
||||
for fb in iter_file_base(index):
|
||||
emit(fb, txt_dir)
|
||||
|
||||
return 0
|
||||
|
||||
def iter_file_base(fn):
|
||||
have_line = iter(open(fn)).next
|
||||
|
||||
while not have_line().startswith('.. toctree'):
|
||||
pass
|
||||
while have_line().strip().startswith(':'):
|
||||
pass
|
||||
|
||||
yield os.path.splitext(os.path.basename(fn))[0]
|
||||
|
||||
n = 0
|
||||
while 1:
|
||||
line = have_line()
|
||||
if line.isspace():
|
||||
continue
|
||||
if line.startswith(".."):
|
||||
break
|
||||
n += 1
|
||||
yield line.strip()
|
||||
|
||||
if n < 5:
|
||||
# maybe format changed?
|
||||
raise Exception("Not enough files found. Format change in index.rst?")
|
||||
|
||||
def emit(basename, txt_dir):
|
||||
for line in open(os.path.join(txt_dir, basename + ".txt")):
|
||||
line = line.replace("``", "'")
|
||||
sys.stdout.write(line)
|
||||
|
||||
# some space between sections
|
||||
print
|
||||
print
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main())
|
||||
|
Loading…
Reference in New Issue
Block a user