-
Notifications
You must be signed in to change notification settings - Fork 45
/
generate_readme.py
executable file
·84 lines (59 loc) · 2.27 KB
/
generate_readme.py
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Created on Sun Apr 20 00:37:12 2014
# License is MIT, see COPYING.txt for more details.
# @author: Danilo de Jesus da Silva Bellini
from __future__ import unicode_literals
import os, io
from test_fractal import show_parameters
template_string = """..
README.rst created with generate_readme.py, don't edit this file manually.
License is MIT, see COPYING.txt for more details.
Fractals in Python
==================
.. image:: https://travis-ci.org/danilobellini/fractal.svg?branch=master
:target: https://travis-ci.org/danilobellini/fractal
Repository with Python code that renders fractals, compatible with both Python
2.7 and 3.2+, showing and saving files with Matplotlib.
For more information about the maths used for fractals (as well as its
history), see the Wikipedia pages about the
`Julia set`_ and `Mandelbrot set`_.
.. _`Julia set`: https://en.wikipedia.org/wiki/Julia_set
.. _`Mandelbrot set`: https://en.wikipedia.org/wiki/Mandelbrot_set
Examples
--------
{% for fname in sorted(listdir("images")) %}
#. {{fname.split("_")[0].capitalize()}} fractal
::
python -m fractal {{show_parameters(fname)}}
.. image:: images/{{fname}}
{% endfor %}
Parameters
----------
Examples above can also be done with a ``--output fractal.png`` parameter,
which saves the example to a image file, while ``--show`` just shows the
raster fractal image on the screen (both parameters can be used together).
For more help, see::
python -m fractal --help
Which shows all options available. To see all colormaps names available in
Matplotlib, see the `colormaps on the scipy wiki`_ or type in a Python shell:
.. code-block:: python
[m for m in __import__("pylab").cm.datad if not m.endswith("_r")]
.. _`colormaps on the scipy wiki`:
http://wiki.scipy.org/Cookbook/Matplotlib/Show_colormaps
----
License is MIT, see `COPYING.txt`_ for more details.
By Danilo J. S. Bellini
.. _`COPYING.txt`: COPYING.txt
"""
kwargs = {
"listdir": os.listdir,
"sorted": sorted,
"show_parameters": show_parameters,
}
if __name__ == "__main__":
import jinja2
template = jinja2.Template(template_string)
readme_data = template.render(**kwargs)
with io.open("README.rst", "w", encoding="utf-8", newline="\r\n") as readme:
readme.write(readme_data)