about summary refs log tree commit diff
path: root/src/etc/rustdoc.py
blob: d5189a19e0f38a59fea3f4d2677d74b5a95df94b (plain)
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
34
# A little helper script for passing rustdoc output through markdown
#  and pandoc

import sys, os, commands;

if len(sys.argv) < 2:
    print("Please provide an input crate")
    sys.exit(1)

crate = sys.argv[1]

status, output = commands.getstatusoutput("rustdoc " + crate)

basename = os.path.splitext(os.path.basename(crate))[0]

markdownfile = basename + ".md"

f = open(markdownfile, 'w')
f.write(output)
f.close()

status, output = commands.getstatusoutput("markdown " + markdownfile)

htmlfile = basename + ".md.html"

f = open(htmlfile, 'w')
f.write(output)
f.close()

pdcmd = "pandoc --standalone --toc --section-divs --number-sections \
         --from=markdown --to=html --css=rust.css \
         --output=" + basename + ".pd.html " + markdownfile

os.system(pdcmd)