|
30 | 30 | except ImportError: |
31 | 31 | using_translations = False |
32 | 32 |
|
| 33 | +try: |
| 34 | + from sphinx.setup_command import BuildDoc |
| 35 | + using_sphinx = True |
| 36 | +except ImportError: |
| 37 | + using_sphinx = False |
| 38 | + |
33 | 39 |
|
34 | 40 | cmdclass = dict(build_py=build_py, build=build) |
35 | 41 | translations_dir = os.path.join(package_dir, 'translations') |
@@ -82,19 +88,35 @@ def initialize_options(self): |
82 | 88 | cmdclass['update_catalog'] = update_catalog |
83 | 89 | cmdclass['init_catalog'] = init_catalog |
84 | 90 |
|
85 | | - |
86 | | -if platform.system() in ['FreeBSD', 'OpenBSD']: |
87 | | - man_dir = 'man' |
| 91 | +if using_sphinx: |
| 92 | + class BuildDocMan(BuildDoc): |
| 93 | + def initialize_options(self): |
| 94 | + BuildDoc.initialize_options(self) |
| 95 | + self.builder = 'man' |
| 96 | + self.source_dir = 'doc/sphinx/source' |
| 97 | + self.build_dir = 'build' |
| 98 | + |
| 99 | + build.sub_commands.insert(0, ('build_sphinx_man', None)) |
| 100 | + cmdclass['build_sphinx_man'] = BuildDocMan |
| 101 | + |
| 102 | + if platform.system() in ['FreeBSD', 'OpenBSD']: |
| 103 | + man_dir = 'man' |
| 104 | + else: |
| 105 | + man_dir = 'share/man' |
| 106 | + |
| 107 | + # manual pages |
| 108 | + man_pages = [ |
| 109 | + (os.path.join(man_dir, 'man1'), ['build/man/bpython.1']), |
| 110 | + (os.path.join(man_dir, 'man5'), ['build/man/bpython-config.5']), |
| 111 | + ] |
88 | 112 | else: |
89 | | - man_dir = 'share/man' |
| 113 | + man_pages = [] |
90 | 114 |
|
91 | 115 | data_files = [ |
92 | | - # man pages |
93 | | - (os.path.join(man_dir, 'man1'), ['doc/bpython.1']), |
94 | | - (os.path.join(man_dir, 'man5'), ['doc/bpython-config.5']), |
95 | 116 | # desktop shortcut |
96 | 117 | (os.path.join('share', 'applications'), ['data/bpython.desktop']) |
97 | 118 | ] |
| 119 | +data_files.extend(man_pages) |
98 | 120 |
|
99 | 121 | # translations |
100 | 122 | mo_files = list() |
|
0 commit comments