Merge lp:~mhall119/developer-ubuntu-com/add-autopilot-scopes-docs into lp:developer-ubuntu-com

Proposed by Michael Hall
Status: Merged
Approved by: Daniel Holbach
Approved revision: 122
Merged at revision: 138
Proposed branch: lp:~mhall119/developer-ubuntu-com/add-autopilot-scopes-docs
Merge into: lp:developer-ubuntu-com
Diff against target: 139 lines (+42/-31)
3 files modified
api_docs/importers/autopilot_sections.py (+3/-0)
api_docs/importers/sphinx.py (+35/-31)
update_apidocs.sh (+4/-0)
To merge this branch: bzr merge lp:~mhall119/developer-ubuntu-com/add-autopilot-scopes-docs
Reviewer Review Type Date Requested Status
Daniel Holbach (community) Approve
Review via email: mp+262859@code.launchpad.net

Description of the change

Add the new python3-scope-harness Autopilot API docs to be auto-imported.

To post a comment you must log in.
Revision history for this message
Daniel Holbach (dholbach) wrote :

Works for me and the code looks cleaner now.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'api_docs/importers/autopilot_sections.py'
2--- api_docs/importers/autopilot_sections.py 2015-04-09 20:43:39 +0000
3+++ api_docs/importers/autopilot_sections.py 2015-06-24 14:45:52 +0000
4@@ -14,6 +14,9 @@
5 'autopilot.gestures': 'Input and Display',
6 'autopilot.input': 'Input and Display',
7
8+ 'scope_harness': 'Scopes',
9+ 'scope_harness.testing': 'Scopes',
10+
11 'tutorial/': 'Tutorials',
12 'guides/': 'Guides',
13 'faq/': 'Frequently Asked Questions',
14
15=== modified file 'api_docs/importers/sphinx.py'
16--- api_docs/importers/sphinx.py 2015-04-16 14:16:26 +0000
17+++ api_docs/importers/sphinx.py 2015-06-24 14:45:52 +0000
18@@ -28,6 +28,7 @@
19 self.sections_file = self.options.get('sections')
20 self.pages_sections = dict()
21 self.page_data_map = dict()
22+ self.module_order = []
23
24 def parse_line(self, line, source_file, element_fullname):
25 line = line.replace(u'\u00b6', u'')
26@@ -213,7 +214,7 @@
27
28 self.PRIMARY_NAMESPACE = None
29
30- namespace_order_index = 0
31+ module_order_index = 0
32
33 DOC_MODULE = '0'
34 DOC_API_PART = '1'
35@@ -242,7 +243,7 @@
36 if page_path.endswith('/'):
37 page_path = page_path[:-1]
38 ns_name = fullname
39- self.namespace_order.append(fullname)
40+ self.module_order.append(fullname)
41 self.namespace_map[fullname] = page_path
42 elif doc_enum == DOC_API_PART:
43 ns_name = '.'.join(fullname.split('.')[:2])
44@@ -281,40 +282,43 @@
45
46 continue
47
48- for ns_name in self.namespace_order:
49- cleaned_ns_name = self.parse_namespace(ns_name)
50-
51- section, created = Section.objects.get_or_create(name=self.get_section(ns_name, None), topic_version=self.version)
52- if created:
53- print "Created section: %s" % section.name
54-
55- if self.verbosity >= 1:
56- print 'Namespace: ' + ns_name
57- print 'Section: ' + section.name
58-
59-
60- doc_file = os.path.join(self.DOC_ROOT, self.namespace_map[ns_name]+'.fjson')
61- ns_data = self.read_json_file(doc_file)
62- classes, extra = self.extract_classes(ns_data['body'])
63-
64- if cleaned_ns_name is not None and cleaned_ns_name != '':
65- namespace, created = Namespace.objects.get_or_create(name=ns_name, display_name=cleaned_ns_name, platform_section=section)
66- if created:
67- print "Created Namespace: %s" % ns_name
68- namespace.data = self.clean_content(extra, doc_file, ns_name)
69- namespace.source_file = os.path.basename(doc_file)
70- namespace.source_format = "sphinx"
71- namespace.save()
72- else:
73- namespace = None
74+ for module in self.module_order:
75+
76+ doc_file = os.path.join(self.DOC_ROOT, self.namespace_map[module]+'.fjson')
77+ module_data = self.read_json_file(doc_file)
78+ classes, extra = self.extract_classes(module_data['body'])
79
80 if len(classes) > 0:
81
82 for fullname, doc_data in classes:
83- if fullname.startswith(ns_name):
84- classname = fullname[len(ns_name)+1:]
85+ if '.' in fullname:
86+ ns_name = fullname[:fullname.rindex('.')]
87+ classname = fullname[fullname.rindex('.')+1:]
88 else:
89 classname = fullname
90+ ns_name = None
91+
92+ cleaned_ns_name = self.parse_namespace(ns_name)
93+
94+ section, created = Section.objects.get_or_create(name=self.get_section(ns_name, None), topic_version=self.version)
95+ if created:
96+ print "Created section: %s" % section.name
97+
98+ if self.verbosity >= 1:
99+ print 'Namespace: ' + ns_name
100+ print 'Section: ' + section.name
101+
102+ if cleaned_ns_name is not None and cleaned_ns_name != '':
103+ namespace, created = Namespace.objects.get_or_create(name=ns_name, display_name=cleaned_ns_name, platform_section=section)
104+ if created:
105+ print "Created Namespace: %s" % ns_name
106+ namespace.data = self.clean_content(extra, doc_file, ns_name)
107+ namespace.source_file = os.path.basename(doc_file)
108+ namespace.source_format = "sphinx"
109+ namespace.save()
110+ else:
111+ namespace = None
112+
113
114 if self.verbosity >= 1:
115 print 'Element: ' + fullname
116@@ -346,7 +350,7 @@
117 if not self.options.get('no_pages', False):
118 page_order_index = 0
119
120- #self.page_order.extend(self.namespace_order)
121+ #self.page_order.extend(self.module_order)
122
123 for pagefile in self.pages_sections:
124 ns_name, pagename, pagefullname, pagetitle = self.page_data_map[pagefile]
125
126=== modified file 'update_apidocs.sh'
127--- update_apidocs.sh 2015-05-12 19:40:04 +0000
128+++ update_apidocs.sh 2015-06-24 14:45:52 +0000
129@@ -90,6 +90,10 @@
130 find /tmp/apidoc_sources/usr/share/doc/ubuntu-ui-toolkit-autopilot/json/ -name "*.gz" -print0 |xargs -0 gunzip
131 python manage.py import_sphinx -t autopilot -l python -r 1.5.0 -s ./api_docs/importers/autopilot_sections.py -i /tmp/apidoc_sources/usr/share/doc/ubuntu-ui-toolkit-autopilot/json/objects.inv
132
133+SERIES=wily ARCH=i386 ./get_package.sh python3-scope-harness
134+find /tmp/apidoc_sources/usr/share/doc/python3-scope-harness/json/ -name "*.gz" -print0 |xargs -0 gunzip
135+python manage.py import_sphinx -t autopilot -l python -r 1.5.0 -s ./api_docs/importers/autopilot_sections.py -i /tmp/apidoc_sources/usr/share/doc/python3-scope-harness/json/objects.inv
136+
137 #### Scopes/C++
138 ## unity.scopes
139 ./get_package.sh libunity-scopes-doc

Subscribers

People subscribed via source and target branches