Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(420)

Side by Side Diff: chrome/common/extensions/docs/server2/reference_resolver.py

Issue 213673002: Add support for "documented_in" annotation in json api schema (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 from copy import deepcopy 5 from copy import deepcopy
6 import logging 6 import logging
7 import re 7 import re
8 8
9 from file_system import FileNotFoundError 9 from file_system import FileNotFoundError
10 10
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 name = name_as_prop_type 107 name = name_as_prop_type
108 text = ref.replace(prop['name'], prop['link']['name']) 108 text = ref.replace(prop['name'], prop['link']['name'])
109 break 109 break
110 if node_info is None: 110 if node_info is None:
111 continue 111 continue
112 else: 112 else:
113 text = ref 113 text = ref
114 category, node_name = node_info 114 category, node_name = node_info
115 if namespace is not None and text.startswith('%s.' % namespace): 115 if namespace is not None and text.startswith('%s.' % namespace):
116 text = text[len('%s.' % namespace):] 116 text = text[len('%s.' % namespace):]
117 api_namespace = self._api_models.GetModel(api_name).Get()
not at google - send to devlin 2014/03/26 22:11:11 api_model also this .Get() will be interesting, h
118 api_name = api_namespace.documentation_options.get('documented_in',
not at google - send to devlin 2014/03/26 22:11:11 |api_name| is not a correct way to refer to this.
119 api_name)
117 return { 120 return {
118 'href': '%s.html#%s-%s' % (api_name, category, name.replace('.', '-')), 121 'href': '%s.html#%s-%s' % (api_name, category, name.replace('.', '-')),
not at google - send to devlin 2014/03/26 22:11:11 we can drop the .html from these now, actually. co
119 'text': text, 122 'text': text,
120 'name': node_name 123 'name': node_name
121 } 124 }
122 125
123 # If it's not a reference to an API node it might just be a reference to an 126 # If it's not a reference to an API node it might just be a reference to an
124 # API. Check this last so that links within APIs take precedence over links 127 # API. Check this last so that links within APIs take precedence over links
125 # to other APIs. 128 # to other APIs.
126 if ref in api_list: 129 if ref in api_list:
127 return { 130 return {
128 'href': '%s.html' % ref, 131 'href': '%s.html' % ref,
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 ref = '' 211 ref = ''
209 rest = ref_and_rest 212 rest = ref_and_rest
210 else: 213 else:
211 ref = match.group() 214 ref = match.group()
212 rest = ref_and_rest[match.end():] 215 rest = ref_and_rest[match.end():]
213 216
214 ref_dict = self.SafeGetLink(ref, namespace=namespace, title=title) 217 ref_dict = self.SafeGetLink(ref, namespace=namespace, title=title)
215 formatted_text.append('<a href="%s%s">%s</a>%s' % 218 formatted_text.append('<a href="%s%s">%s</a>%s' %
216 (link_prefix, ref_dict['href'], ref_dict['text'], rest)) 219 (link_prefix, ref_dict['href'], ref_dict['text'], rest))
217 return ''.join(formatted_text) 220 return ''.join(formatted_text)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698