forked from facebookarchive/three20
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocs.py
executable file
·135 lines (100 loc) · 3.87 KB
/
docs.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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#!/usr/bin/env python
# encoding: utf-8
"""
docs.py
Created by Jeff Verkoeyen on 2010-10-18.
Copyright 2009-2010 Facebook
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""
import logging
import re
import os
import sys
import shutil
import errno
import git
# Three20 Python Objects
import Paths
from optparse import OptionParser
def generate_appledoc(version):
logging.info("Generating appledoc")
os.system("appledoc " +
"--project-name Three20 " +
"--project-company \"Facebook\" " +
"--company-id=com.facebook " +
"--output Docs/ " +
"--project-version " + version + " " +
"--ignore .m --ignore Vendors --ignore UnitTests " +
"--keep-undocumented-objects " +
"--keep-undocumented-members " +
"--warn-undocumented-object " +
"--warn-undocumented-member " +
"--warn-empty-description " +
"--warn-unknown-directive " +
"--warn-invalid-crossref " +
"--warn-missing-arg " +
"--keep-intermediate-files " +
"--docset-feed-name \"Three20 " + version + " Documentation\" " +
"--docset-feed-url http://facebook.github.com/three20/api/%DOCSETATOMFILENAME " +
"--docset-package-url http://facebook.github.com/three20/api/%DOCSETPACKAGEFILENAME " +
"--publish-docset " +
"--verbose 5 src/")
def publish_ghpages(version):
logging.info("Cloning and checking out gh-pages")
os.system("git clone [email protected]:facebook/three20.git Docs/gh-pages")
os.system("cd Docs/gh-pages && git pull")
os.system("cd Docs/gh-pages && git checkout gh-pages")
logging.info("Copying docset into gh-pages folder")
os.system("cp -r -f Docs/html/* Docs/gh-pages/api")
os.system("cp -r -f Docs/publish/ Docs/gh-pages/api")
logging.info("Committing new docs")
os.system("cd Docs/gh-pages && git add -A .")
os.system("cd Docs/gh-pages && git commit -am \"Three20 " + version + " Documentation\"")
os.system("cd Docs/gh-pages && git push origin gh-pages")
def main():
usage = '''%prog [options]
The Three20 Appledoc Generator Script.
Use this script to generate appledoc
--generate will generate the docs
--publish will publish the new docs into the three20's gh-pages branch
EXAMPLES:
Most common use case:
> %prog --version 1.0.10-dev --generate
'''
parser = OptionParser(usage = usage)
parser.add_option("-o", "--generate", dest="generate",
help="Generate appledoc",
action="store_true")
parser.add_option("-p", "--publish", dest="publish",
help="publish gh-pages",
action="store_true")
parser.add_option("-v", "--version", dest="version",
help="Project version")
parser.add_option("", "--verbose", dest="verbose",
help="Display verbose output",
action="store_true")
(options, args) = parser.parse_args()
if options.verbose:
log_level = logging.INFO
else:
log_level = logging.WARNING
logging.basicConfig(level=log_level)
did_anything = False
if options.generate:
did_anything = True
generate_appledoc(options.version)
if options.publish:
did_anything = True
publish_ghpages(options.version)
if not did_anything:
parser.print_help()
if __name__ == "__main__":
sys.exit(main())