File: doc_mod.py

package info (click to toggle)
dipy 1.3.0-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 14,828 kB
  • sloc: python: 63,790; makefile: 258; pascal: 167; sh: 131; ansic: 106
file content (33 lines) | stat: -rwxr-xr-x 709 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env python
""" Make documentation for module

Depends on some guessed filepaths

Filepaths guessed by importing
"""

import sys
from os.path import join as pjoin, dirname, abspath
ROOT_DIR = abspath(pjoin(dirname(__file__), '..'))
DOC_SDIR = pjoin(ROOT_DIR, 'doc', 'reference')

TEMPLATE = \
""":mod:`%s`
=========================

.. automodule:: %s
    :members:
"""

def main():
    try:
        mod_name = sys.argv[1]
    except IndexError:
        raise OSError('Need module import as input')
    out_fname = pjoin(DOC_SDIR, mod_name + '.rst')
    open(out_fname, 'wt').write(TEMPLATE % (mod_name,
                                            mod_name))


if __name__ == '__main__':
    main()