Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/utils/generar_resumen_api.py
blob: 028df6f3df65a5b7f427da1f7eb9bf2c368c76c7 (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
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
# -*- encoding: utf-8 -*-
# Genera el contenido del archivo pilas.rst que describe
# toda la api de pilas y se agrega al manual como anexo.

import os
import re


content = []

for x in os.walk("../pilas"):

    for filename in x[2]:
        if filename.endswith(".py") and not filename.startswith("__"):
            fullname = x[0] + '/' + filename[:-3]
            
            fullname = fullname.replace("../", "")
            fullname = fullname.replace("/", ".")

            if "test" not in fullname and "__" not in fullname and "rope" not in fullname and "cargador" not in fullname:
                title = fullname
                content.append(title)
                content.append("-" * len(title))

                content.append("")
                content.append("")

                archivo = open(os.path.join(x[0], filename), "rt")

                contenido = archivo.readlines()

                for linea in contenido:
                    class_name = re.match("class (.+)\((\S*)\):", linea)

                    if class_name:
                        content.append("")
                        content.append("")
                        content.append("class **%s** (%s)" %(class_name.group(1), class_name.group(2)))
                        content.append("")

                    method = re.match("\s*def (.+)\((\S+)\):", linea)

                    if method:
                        argumentos = method.group(2).replace("*", "x")
                        argumentos = argumentos.replace("self", "")
                        content.append("- **%s** (%s)" %(method.group(1), argumentos))
                        
                        

                archivo.close()
                content.append("")



print '\n'.join(content)
print "Actualizando el archivo 'resumen_api.rst"
archivo = open("resumen_api.rst", "wt")
archivo.write("\n".join(content))
archivo.close()