Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e8548da

Browse files
committed
finished the first cut at the examples for search support
svn path=/trunk/matplotlib/; revision=6230
1 parent b80e228 commit e8548da

4 files changed

Lines changed: 82 additions & 25 deletions

File tree

doc/_templates/indexsidebar.html

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,16 @@ <h3>Download</h3>
1212
</p>
1313

1414
<h3>Need help?</h3>
15-
<p>Check the <a href="{{ pathto('users/index') }}">user</a> guide, the <a
16-
href="{{ pathto('faq/index') }}">faq</a>, the <a href="{{
17-
pathto('api/index') }}"}>api</a> docs, <a href=http://www.nabble.com/matplotlib---users-f2906.html>archives</a>, and join the matplotlib mailing <a
18-
href="http://sourceforge.net/mail/?group_id=80706">lists</a>
15+
<p>Check the <a href="{{ pathto('users/index') }}">user</a> guide,
16+
the <a href="{{ pathto('faq/index') }}">faq</a>, the <a href="{{
17+
pathto('api/index') }}"}>api</a> docs,
18+
<a href=http://www.nabble.com/matplotlib---users-f2906.html>archives</a>,
19+
and join the matplotlib
20+
mailing <a href="http://sourceforge.net/mail/?group_id=80706">lists</a>.
21+
The <a href="{{ pathto('search') }}">search</a>|&nbsp;</li> tool
22+
searches all of the documentation, including full text search of
23+
almost 300 complete examples which exercise almost every corner of
24+
matplotlib.
1925

2026
<p>You can file bugs, patches and feature requests on the sourceforge <a href="http://sourceforge.net/tracker2/?group_id=80706">tracker</a>, but it is a good idea to ping us on the mailing list too.</p>
2127

@@ -24,7 +30,7 @@ <h3>Screenshots</h3>
2430
<a href="{{ pathto('users/screenshots') }}"><img align=center src="{{
2531
pathto('_static/logo_sidebar.png', 1) }} "border="0"></a>
2632

27-
<a href="{{ pathto('users/screenshots') }}">screenshots</a> and <a href=examples>examples</a>
33+
<a href="{{ pathto('users/screenshots') }}">screenshots</a> and <a href=examples/index.html>examples</a>
2834

2935
<h3>Other stuff</h3>
3036

doc/_templates/layout.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{% extends "!layout.html" %}
22

33
{% block rootrellink %}
4-
<li><a href="{{ pathto('index') }}">matplotlib&nbsp;home </a> |&nbsp;</li>
4+
<li><a href="{{ pathto('index') }}">matplotlib&nbsp;home</a>|&nbsp;</li>
5+
<li><a href="{{ pathto('search') }}">search</a>|&nbsp;</li>
56
<li><a href="{{ pathto('contents') }}">documentation </a> &raquo;</li>
67
{% endblock %}
78

doc/examples/gen_rst.py

Lines changed: 62 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,13 @@
1414
datad = {}
1515
for root, subFolders, files in os.walk(rootdir):
1616
for fname in files:
17-
if ( fname.startswith('.') or fname.startswith('#') or
17+
if ( fname.startswith('.') or fname.startswith('#') or fname.startswith('_') or
1818
fname.find('.svn')>=0 or not fname.endswith('.py') ):
1919
continue
2020

2121
fullpath = os.path.join(root,fname)
2222
contents = file(fullpath).read()
2323
# indent
24-
contents = '\n'.join([' %s'%row.rstrip() for row in contents.split('\n')])
2524
relpath = os.path.split(root)[-1]
2625
datad.setdefault(relpath, []).append((fname, contents))
2726

@@ -47,32 +46,77 @@
4746
""")
4847

4948
for subdir in subdirs:
50-
print subdir
51-
outfile = '%s.rst'%subdir
52-
fh = file(outfile, 'w')
49+
if not os.path.exists(subdir):
50+
os.makedirs(subdir)
51+
52+
static_dir = os.path.join('..', '_static', 'examples')
53+
if not os.path.exists(static_dir):
54+
os.makedirs(static_dir)
55+
56+
static_dir = os.path.join(static_dir, subdir)
57+
if not os.path.exists(static_dir):
58+
os.makedirs(static_dir)
59+
60+
61+
subdirIndexFile = os.path.join(subdir, 'index.rst')
62+
fhsubdirIndex = file(subdirIndexFile, 'w')
63+
fhindex.write(' %s\n'%subdirIndexFile)
64+
65+
66+
fhsubdirIndex.write("""\
67+
.. _%s-examples-index:
68+
69+
70+
##############################################
71+
%s Examples
72+
##############################################
73+
74+
.. htmlonly::
75+
76+
:Release: |version|
77+
:Date: |today|
78+
79+
.. toctree::
80+
:maxdepth: 1
81+
82+
"""%(subdir, subdir))
5383

54-
fhindex.write(' %s\n'%outfile)
84+
print subdir
5585

56-
fh.write('.. _%s-examples:\n\n'%subdir)
57-
title = '%s examples'%subdir
86+
87+
data = datad[subdir]
88+
data.sort()
89+
for fname, contents in data:
5890

59-
fh.write('*'*len(title) + '\n')
60-
fh.write(title + '\n')
61-
fh.write('*'*len(title) + '\n\n')
91+
static_file = os.path.join(static_dir, fname)
92+
fhstatic = file(static_file, 'w')
93+
fhstatic.write(contents)
94+
fhstatic.close()
6295

63-
for fname, contents in datad[subdir]:
64-
print ' ', fname
6596
basename, ext = os.path.splitext(fname)
66-
fh.write('.. _%s-example:\n\n'%basename)
67-
title = '%s example'%basename
97+
rstfile = '%s.rst'%basename
98+
outfile = os.path.join(subdir, rstfile)
99+
fhsubdirIndex.write(' %s\n'%rstfile)
100+
fh = file(outfile, 'w')
101+
fh.write('.. _%s-%s:\n\n'%(subdir, basename))
102+
title = '%s example code: %s'%(subdir, fname)
68103

69104
fh.write(title + '\n')
70105
fh.write('='*len(title) + '\n\n')
71-
fh.write(fname + '::\n\n')
106+
107+
108+
print ' %s'%fname
109+
110+
linkname = os.path.join('..', '..', '_static', 'examples', subdir, fname)
111+
fh.write('%s (`link to source <%s>`_)::\n\n'%(fname, linkname))
112+
113+
# indent the contents
114+
contents = '\n'.join([' %s'%row.rstrip() for row in contents.split('\n')])
115+
72116
fh.write(contents)
73117
fh.write('\n\n')
74-
fh.close()
75-
118+
fh.close()
76119

120+
fhsubdirIndex.close()
77121

78122
fhindex.close()

doc/make.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ def check_build():
1717
def sf():
1818
'push a copy to the sf site'
1919
os.system('cd build/html; rsync -avz . jdh2358,[email protected]:/home/groups/m/ma/matplotlib/htdocs/ -essh')
20-
os.system('cd ~/mpl/examples; svn-clean; cd ..; rsync -avz examples jdh2358,[email protected]:/home/groups/m/ma/matplotlib/htdocs/ -essh --cvs-exclude --delete')
20+
# we are now doing this in the doc/examples build
21+
#os.system('cd ~/mpl/examples; svn-clean; cd ..; rsync -avz examples jdh2358,[email protected]:/home/groups/m/ma/matplotlib/htdocs/ -essh --cvs-exclude --delete')
2122

2223
def sfpdf():
2324
'push a copy to the sf site'
@@ -28,6 +29,11 @@ def figs():
2829

2930
def html():
3031
check_build()
32+
# build the literal include examples for searchable examples
33+
os.system('cd examples; python gen_rst.py')
34+
35+
36+
3137
#figs()
3238
if os.system('sphinx-build -b html -d build/doctrees . build/html'):
3339
raise SystemExit("Building HTML failed.")

0 commit comments

Comments
 (0)