This repository has been archived by the owner on Mar 21, 2024. It is now read-only.
/
gen-readme.py
executable file
·112 lines (88 loc) · 2.11 KB
/
gen-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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/usr/bin/env python
"""Generate the readme from module doc."""
import codecs
import os
import subprocess
import pure_func
with codecs.open("README.rst", "w") as f:
f.write("""
=========
Pure-func
=========
|travis| |pypi|
.. |travis| image:: https://travis-ci.org/adfinis-sygroup/pure_func.svg?branch=master # noqa
:target: https://travis-ci.org/adfinis-sygroup/pure_func
.. |pypi| image:: https://badge.fury.io/py/pure-func.svg
:target: https://badge.fury.io/py/pure-func
""")
f.write(pure_func.__doc__)
f.write("""
@pure_check()
=============
""")
f.write(os.linesep.join([
line.lstrip() for line in
pure_func.pure_check.__doc__.splitlines()
]))
f.write("""
@gcd_lru_cache(maxsize=128, typed=False)
========================================
""")
f.write(os.linesep.join([
line.lstrip() for line in
pure_func.gcd_lru_cache.__doc__.splitlines()
]))
f.write("""
@pure_sampling(base=2)
======================
""")
f.write(os.linesep.join([
line.lstrip() for line in
pure_func.pure_sampling.__doc__.splitlines()
]))
f.write("""
with checking()
===============
""")
f.write(os.linesep.join([
line.lstrip() for line in
pure_func.checking.__doc__.splitlines()
]))
f.write("""
@checked()
==========
""")
f.write(os.linesep.join([
line.lstrip() for line in
pure_func.checked.__doc__.splitlines()
]))
f.write("""
Performance
===========
.. code-block:: text
""")
proc = subprocess.Popen(
["python", "tests.py"],
stdout=subprocess.PIPE
)
while True:
line = proc.stdout.readline()
if line:
if b"(took " in line:
f.write(" %s\n" % line.strip().decode("UTF-8"))
else:
break
proc.wait()
f.write("""
Note that the fibonacci function is very short, please compare to the expansive
fibonacci tests.
License
=======
MIT
Changelog
=========
1.2 - 2017-04-19
----------------
* Fix setup.py to point to the correct homepage (@lucaswiman)
* Fix @pure_sampling(base=1) not checking at all
""")