fgdocx  0.2 [master]
FlightGear API Docs
build_docs.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 ## @package fgdocx
4 # This script does all the handling of the docs build process
5 #
6 # @author Pete Morgan
7 # @version 0.1.exp
8 #
9 
10 
11 import os
12 
13 from optparse import OptionParser
14 
15 
16 from fgdocx.builder import DocsBuilder
17 
18 
19 ## Handle Command Args
20 usage = "usage: %prog [options] COMMAND proj1 proj2 .. projn\n"
21 usage += " commands are\n"
22 usage += " view - to view the config\n"
23 usage += " build proj1 proj2 - Build one or more projects\n"
24 usage += " buildall - Build all projects\n"
25 parser = OptionParser(usage=usage)
26 parser.add_option( "-z", "--zip",
27  action="store_false", dest="zip", default=False,
28  help="Create zip file"
29  )
30 parser.add_option( "-v", "--verbose", nargs=1,
31  action="store", type="int", dest="v", default=1,
32  help="Prints more output 0-4 (0=none, 4=loads)"
33  )
34 
35 (opts, args) = parser.parse_args()
36 
37 
38 docsBuilder = DocsBuilder(parser, opts, args)
39 
40 
41 
42 
43 ##############################################################################
44 
45 
46 
47 
48 ## Get the projects index as a list of dicts. This loops thru the projects and reads the INFO_JSON_FILE_FILE
50  ret = []
51  for proj in sorted(conf.keys()):
52  pconf = conf[proj]
53  is_main = proj == "fg-docs"
54  js_filen = BUILD + INFO_JSON_FILE if is_main else BUILD + proj + "/" + INFO_JSON_FILE
55  data = None
56  if os.path.exists(js_filen):
57  json_str = read_file(js_filen)
58  data = json.loads(json_str)
59  print data
60  #if c != "fg-docs":
61  p = XObject()
62  p.proj = proj
63  p.color = pconf['color'] if 'color' in pconf else "blue"
64  p.version = data['version'] if data else pconf['version']['number']
65  p.title = pconf['title']
66  p.repo = pconf['repo']
67  p.checkout = pconf['checkout']
68  p.date_updated = data["date_updated"] if "date_updated" in data else ""
69  ret.append( p )
70  return ret
71 
72 
73 
74 
def DEADget_projects_index()
Get the projects index as a list of dicts.
Definition: build_docs.py:49
def read_file(path_to_file)
Read a text file and return its contents.
Definition: helpers.py:8