| 8 | import sys |
| 9 | |
| 10 | class SphinxOutputFormat: |
| 11 | def __init__(self, name, pre_args): |
| 12 | self.name = str(name) |
| 13 | self.pre_args = tuple(pre_args) |
| 14 | |
| 15 | @property |
| 16 | def args(self): |
| 17 | output_dir = os.path.join('docs', self.name) |
| 18 | artifacts_dir = os.path.join('build', 'docs', self.name) # for artifacts not part of the final documentation |
| 19 | os.makedirs(artifacts_dir, mode=0o755, exist_ok=True) |
| 20 | return [ |
| 21 | *self.pre_args, |
| 22 | '.', # source dir |
| 23 | output_dir, |
| 24 | '-d', artifacts_dir, |
| 25 | '-w', os.path.join(artifacts_dir, 'sphinx-warnings.txt'), |
| 26 | ] |
| 27 | |
| 28 | OUTPUT_FORMATS = { |
| 29 | 'html': SphinxOutputFormat('html', pre_args=['-b', 'html']), |