{% trans %}Error{% endtrans %}
16 |17 | {% trans %}Please activate JavaScript to enable the search functionality.{% endtrans %} 18 |
19 |') 212 | lines[0:1] = [before + '', after] 213 | 214 | # nothing to do for the last line; it always starts withanyway 215 | # now that we have code lines (starting at index 1), insert anchors for 216 | # the collected tags (HACK: this only works if the tag boundaries are 217 | # properly nested!) 218 | maxindex = len(lines) - 1 219 | for name, (type_, start, end) in tags.items(): 220 | docname = 'api' 221 | backlink = urito(pagename, docname) + '#' + refname + '.' + name 222 | 223 | if name in used: 224 | a_elem = '{} '.format(backlink, _('[docs]')) 225 | else: 226 | a_elem = '' 227 | 228 | file_ = modname.replace('.', '/') + '.py' 229 | github_line_link = get_github_line_link(app, file_, start, min(end, maxindex)) 230 | if github_line_link is not None: 231 | github_a_elem = '{}'.format(github_line_link, _('[github]')) 232 | else: 233 | github_a_elem = '' 234 | 235 | div_elem = ''.format(name) 236 | 237 | lines[start] = div_elem + github_a_elem + a_elem + lines[start] 238 | lines[min(end, maxindex)] += '' 239 | 240 | # try to find parents (for submodules) 241 | parents = [] 242 | parent = modname 243 | while '.' in parent: 244 | parent = parent.rsplit('.', 1)[0] 245 | if parent in modnames: 246 | parents.append({ 247 | 'link': urito(pagename, '_modules/' + 248 | parent.replace('.', '/')), 249 | 'title': parent}) 250 | parents.append({'link': urito(pagename, '_modules/index'), 251 | 'title': _('Module code')}) 252 | parents.reverse() 253 | 254 | # putting it all together 255 | context = { 256 | 'parents': parents, 257 | 'title': modname, 258 | 'body': (_('Source code for %s
') % modname + 259 | '\n'.join(lines)), 260 | } 261 | yield (pagename, context, 'page.html') 262 | 263 | if not modnames: 264 | return 265 | 266 | html = ['\n'] 267 | # the stack logic is needed for using nested lists for submodules 268 | stack = [''] 269 | for modname in sorted(modnames): 270 | if modname.startswith(stack[-1]): 271 | stack.append(modname + '.') 272 | html.append('