Mercurial > p > roundup > code
annotate roundup/dist/command/build_doc.py @ 8528:fed0f839c260
fix: replace except: with except Exception: (by haosenwang1018@github)
Remove bare 'except:' statements replace with 'except Exception'.
In roundup_xmlrpc_server.py I changed Exception to BaseException so
the database gets closed on signals as well. The rest of the changes
do not look like they affect data integrity and are commited as
supplied.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Thu, 26 Feb 2026 09:46:02 -0500 |
| parents | d2ca7b1bfc6b |
| children |
| rev | line source |
|---|---|
|
4033
bca7c59ac400
Enhance documentation generation.
Stefan Seefeld <stefan@seefeld.name>
parents:
diff
changeset
|
1 # |
|
bca7c59ac400
Enhance documentation generation.
Stefan Seefeld <stefan@seefeld.name>
parents:
diff
changeset
|
2 # Copyright (C) 2009 Stefan Seefeld |
|
bca7c59ac400
Enhance documentation generation.
Stefan Seefeld <stefan@seefeld.name>
parents:
diff
changeset
|
3 # All rights reserved. |
|
bca7c59ac400
Enhance documentation generation.
Stefan Seefeld <stefan@seefeld.name>
parents:
diff
changeset
|
4 # For license terms see the file COPYING.txt. |
|
bca7c59ac400
Enhance documentation generation.
Stefan Seefeld <stefan@seefeld.name>
parents:
diff
changeset
|
5 # |
|
bca7c59ac400
Enhance documentation generation.
Stefan Seefeld <stefan@seefeld.name>
parents:
diff
changeset
|
6 |
|
bca7c59ac400
Enhance documentation generation.
Stefan Seefeld <stefan@seefeld.name>
parents:
diff
changeset
|
7 import os, sys |
|
bca7c59ac400
Enhance documentation generation.
Stefan Seefeld <stefan@seefeld.name>
parents:
diff
changeset
|
8 import os.path |
|
bca7c59ac400
Enhance documentation generation.
Stefan Seefeld <stefan@seefeld.name>
parents:
diff
changeset
|
9 |
|
6647
42bf0a707763
issue2551183 - Replace references to distutils in roundup/dist/command
John Rouillard <rouilj@ieee.org>
parents:
5074
diff
changeset
|
10 try: |
|
42bf0a707763
issue2551183 - Replace references to distutils in roundup/dist/command
John Rouillard <rouilj@ieee.org>
parents:
5074
diff
changeset
|
11 from setuptools.command.install import install as _build_py |
|
42bf0a707763
issue2551183 - Replace references to distutils in roundup/dist/command
John Rouillard <rouilj@ieee.org>
parents:
5074
diff
changeset
|
12 except ImportError: |
|
42bf0a707763
issue2551183 - Replace references to distutils in roundup/dist/command
John Rouillard <rouilj@ieee.org>
parents:
5074
diff
changeset
|
13 from distutils.command.build import build as _build_py # try/except clause |
|
42bf0a707763
issue2551183 - Replace references to distutils in roundup/dist/command
John Rouillard <rouilj@ieee.org>
parents:
5074
diff
changeset
|
14 orig_build = _build_py |
|
4033
bca7c59ac400
Enhance documentation generation.
Stefan Seefeld <stefan@seefeld.name>
parents:
diff
changeset
|
15 |
|
6647
42bf0a707763
issue2551183 - Replace references to distutils in roundup/dist/command
John Rouillard <rouilj@ieee.org>
parents:
5074
diff
changeset
|
16 try: |
|
42bf0a707763
issue2551183 - Replace references to distutils in roundup/dist/command
John Rouillard <rouilj@ieee.org>
parents:
5074
diff
changeset
|
17 # would be nice to use setuptools.Command.spawn() as it |
|
42bf0a707763
issue2551183 - Replace references to distutils in roundup/dist/command
John Rouillard <rouilj@ieee.org>
parents:
5074
diff
changeset
|
18 # obeys the dry-run flag. |
|
42bf0a707763
issue2551183 - Replace references to distutils in roundup/dist/command
John Rouillard <rouilj@ieee.org>
parents:
5074
diff
changeset
|
19 from subprocess import run as spawn |
|
42bf0a707763
issue2551183 - Replace references to distutils in roundup/dist/command
John Rouillard <rouilj@ieee.org>
parents:
5074
diff
changeset
|
20 except ImportError: |
|
42bf0a707763
issue2551183 - Replace references to distutils in roundup/dist/command
John Rouillard <rouilj@ieee.org>
parents:
5074
diff
changeset
|
21 from distutils.spawn import spawn # try/except: in except for subprocess |
|
42bf0a707763
issue2551183 - Replace references to distutils in roundup/dist/command
John Rouillard <rouilj@ieee.org>
parents:
5074
diff
changeset
|
22 |
|
42bf0a707763
issue2551183 - Replace references to distutils in roundup/dist/command
John Rouillard <rouilj@ieee.org>
parents:
5074
diff
changeset
|
23 try: |
|
42bf0a707763
issue2551183 - Replace references to distutils in roundup/dist/command
John Rouillard <rouilj@ieee.org>
parents:
5074
diff
changeset
|
24 from distutils.spawn import find_executable # try/except: in try local find |
|
42bf0a707763
issue2551183 - Replace references to distutils in roundup/dist/command
John Rouillard <rouilj@ieee.org>
parents:
5074
diff
changeset
|
25 except ImportError: |
|
42bf0a707763
issue2551183 - Replace references to distutils in roundup/dist/command
John Rouillard <rouilj@ieee.org>
parents:
5074
diff
changeset
|
26 from roundup.dist.command import find_executable |
|
42bf0a707763
issue2551183 - Replace references to distutils in roundup/dist/command
John Rouillard <rouilj@ieee.org>
parents:
5074
diff
changeset
|
27 |
|
42bf0a707763
issue2551183 - Replace references to distutils in roundup/dist/command
John Rouillard <rouilj@ieee.org>
parents:
5074
diff
changeset
|
28 class build_doc(_build_py): |
|
4033
bca7c59ac400
Enhance documentation generation.
Stefan Seefeld <stefan@seefeld.name>
parents:
diff
changeset
|
29 """Defines the specific procedure to build roundup's documentation.""" |
|
bca7c59ac400
Enhance documentation generation.
Stefan Seefeld <stefan@seefeld.name>
parents:
diff
changeset
|
30 |
|
bca7c59ac400
Enhance documentation generation.
Stefan Seefeld <stefan@seefeld.name>
parents:
diff
changeset
|
31 description = "build documentation" |
|
bca7c59ac400
Enhance documentation generation.
Stefan Seefeld <stefan@seefeld.name>
parents:
diff
changeset
|
32 |
|
bca7c59ac400
Enhance documentation generation.
Stefan Seefeld <stefan@seefeld.name>
parents:
diff
changeset
|
33 def run(self): |
|
bca7c59ac400
Enhance documentation generation.
Stefan Seefeld <stefan@seefeld.name>
parents:
diff
changeset
|
34 """Run this command, i.e. do the actual document generation.""" |
|
bca7c59ac400
Enhance documentation generation.
Stefan Seefeld <stefan@seefeld.name>
parents:
diff
changeset
|
35 |
|
bca7c59ac400
Enhance documentation generation.
Stefan Seefeld <stefan@seefeld.name>
parents:
diff
changeset
|
36 sphinx = find_executable('sphinx-build') |
|
4810
7b575e1f7368
setup.py build_doc: try Python-installed Sphinx if command
anatoly techtonik <techtonik@gmail.com>
parents:
4033
diff
changeset
|
37 if sphinx: |
|
7b575e1f7368
setup.py build_doc: try Python-installed Sphinx if command
anatoly techtonik <techtonik@gmail.com>
parents:
4033
diff
changeset
|
38 sphinx = [sphinx] |
|
7b575e1f7368
setup.py build_doc: try Python-installed Sphinx if command
anatoly techtonik <techtonik@gmail.com>
parents:
4033
diff
changeset
|
39 else: |
|
7b575e1f7368
setup.py build_doc: try Python-installed Sphinx if command
anatoly techtonik <techtonik@gmail.com>
parents:
4033
diff
changeset
|
40 try: # try to find version installed with Python tools |
|
7b575e1f7368
setup.py build_doc: try Python-installed Sphinx if command
anatoly techtonik <techtonik@gmail.com>
parents:
4033
diff
changeset
|
41 # tested with Sphinx 1.1.3 |
|
7b575e1f7368
setup.py build_doc: try Python-installed Sphinx if command
anatoly techtonik <techtonik@gmail.com>
parents:
4033
diff
changeset
|
42 import sphinx as sp |
|
7b575e1f7368
setup.py build_doc: try Python-installed Sphinx if command
anatoly techtonik <techtonik@gmail.com>
parents:
4033
diff
changeset
|
43 except ImportError: |
|
7b575e1f7368
setup.py build_doc: try Python-installed Sphinx if command
anatoly techtonik <techtonik@gmail.com>
parents:
4033
diff
changeset
|
44 pass |
|
7b575e1f7368
setup.py build_doc: try Python-installed Sphinx if command
anatoly techtonik <techtonik@gmail.com>
parents:
4033
diff
changeset
|
45 else: |
|
7b575e1f7368
setup.py build_doc: try Python-installed Sphinx if command
anatoly techtonik <techtonik@gmail.com>
parents:
4033
diff
changeset
|
46 sphinx = [sys.executable, sp.__file__] |
|
7b575e1f7368
setup.py build_doc: try Python-installed Sphinx if command
anatoly techtonik <techtonik@gmail.com>
parents:
4033
diff
changeset
|
47 |
|
4033
bca7c59ac400
Enhance documentation generation.
Stefan Seefeld <stefan@seefeld.name>
parents:
diff
changeset
|
48 if not sphinx: |
|
bca7c59ac400
Enhance documentation generation.
Stefan Seefeld <stefan@seefeld.name>
parents:
diff
changeset
|
49 self.warn("could not find sphinx-build in PATH") |
|
bca7c59ac400
Enhance documentation generation.
Stefan Seefeld <stefan@seefeld.name>
parents:
diff
changeset
|
50 self.warn("cannot build documentation") |
|
bca7c59ac400
Enhance documentation generation.
Stefan Seefeld <stefan@seefeld.name>
parents:
diff
changeset
|
51 return |
|
bca7c59ac400
Enhance documentation generation.
Stefan Seefeld <stefan@seefeld.name>
parents:
diff
changeset
|
52 |
|
bca7c59ac400
Enhance documentation generation.
Stefan Seefeld <stefan@seefeld.name>
parents:
diff
changeset
|
53 doc_dir = os.path.join('share', 'doc', 'roundup', 'html') |
|
7416
302ce182ffd3
Replace build_temp with build_base
John Rouillard <rouilj@ieee.org>
parents:
7412
diff
changeset
|
54 temp_dir = os.path.join(self.build_base, 'temp.doc') |
|
4810
7b575e1f7368
setup.py build_doc: try Python-installed Sphinx if command
anatoly techtonik <techtonik@gmail.com>
parents:
4033
diff
changeset
|
55 cmd = sphinx + ['-d', temp_dir, 'doc', doc_dir] |
|
4033
bca7c59ac400
Enhance documentation generation.
Stefan Seefeld <stefan@seefeld.name>
parents:
diff
changeset
|
56 spawn(cmd) |
