Skip to content

Commit 7857dcb

Browse files
committed
rustdoc: Add a script for running rustdoc output through markdown/pandoc
1 parent 7c1d1d6 commit 7857dcb

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

src/etc/rustdoc.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# A little helper script for passing rustdoc output through markdown
2+
# and pandoc
3+
4+
import sys, os, commands;
5+
6+
if len(sys.argv) < 2:
7+
print("Please provide an input crate")
8+
sys.exit(1)
9+
10+
crate = sys.argv[1]
11+
12+
status, output = commands.getstatusoutput("rustdoc " + crate)
13+
14+
basename = os.path.splitext(os.path.basename(crate))[0]
15+
16+
markdownfile = basename + ".md"
17+
18+
f = open(markdownfile, 'w')
19+
f.write(output)
20+
f.close()
21+
22+
status, output = commands.getstatusoutput("markdown " + markdownfile)
23+
24+
htmlfile = basename + ".md.html"
25+
26+
f = open(htmlfile, 'w')
27+
f.write(output)
28+
f.close()
29+
30+
pdcmd = "pandoc --standalone --toc --section-divs --number-sections \
31+
--from=markdown --to=html --css=rust.css \
32+
--output=" + basename + ".pd.html " + markdownfile
33+
34+
os.system(pdcmd)

0 commit comments

Comments
 (0)