forked from Dramac/TriViSiJu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
writedoc
executable file
·84 lines (69 loc) · 2.74 KB
/
writedoc
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 -*-
""" TriViSiJu: Graphical interface for the AstroJeune Festival
Copyright (C) 2012 Jules DAVID, Tristan GREGOIRE, Simon NICOLAS and Vincent PRAT
This file is part of TriViSiJu.
TriViSiJu is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
TriViSiJu is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with TriViSiJu. If not, see <http://www.gnu.org/licenses/>.
"""
import os
import pydoc
import re
import main
import fonction
import modules
## Paramètres
# Repertoire de stockage de la documentation
doc = "doc/dev"
# Liste des modules python
listmodule = ["os", "gtk", "pygtk", "time", "ConfigParser", "argparse",\
"sys", "gobject", "Image", "subprocess", "tempfile",\
"hashlib", "pickle"]
# Création de la documentation de premier niveau
print ">> Documentation 1er niveau :"
pydoc.writedoc(main)
pydoc.writedoc(fonction)
pydoc.writedoc(modules)
# Liste des fichiers du dossier modules
print ">> Documentation 2nd niveau :"
modules = os.listdir('./modules')
# Création de la documentation de deuxième niveau
for item in modules:
if re.search("\.py$",item) and item != '__init__.py':
item = "modules."+item.replace(".py","")
pydoc.writedoc(item)
# Creation de la doc des modules python utilisés
print ">> Documentation Python et autres librairies externes :"
for mod in listmodule:
pydoc.writedoc(mod)
# Liste des fichiers du dossier racine
files = os.listdir('.')
# Déplacement et correction de l'encodage
print "\n>> Correction de l'encodage"
if not os.path.isdir(doc):
print "Creation du repertoire '%s'"%(doc)
os.system("mkdir -p %s"%(doc))
for item in files:
if re.search("\.html$",item):
# correction de l'encodage (ajout de <meta charset=utf-8 /> dans le head)
old_file = open(item)
new_file = open(item+".tmp","w")
for line in old_file.readlines():
if re.search(r"<html><head>",line):
line = line.replace("<head>","<head><meta charset=utf-8 />")
new_file.write(line)
old_file.close()
new_file.close()
os.remove(item)
# Déplacement vers le dossier doc/
os.rename(item+".tmp", os.path.join(doc, item))
print "Done"
print "\nLa documentation a été générée dans le dossier '%s'\n"%(doc)