Return a link for a single "@{symbol}" reference.
(self, match, relative_path_to_root)
| 375 | return os.path.join(relative_path_to_root, ref_path) |
| 376 | |
| 377 | def _one_ref(self, match, relative_path_to_root): |
| 378 | """Return a link for a single "@{symbol}" reference.""" |
| 379 | string = match.group(1) |
| 380 | |
| 381 | # Look for link text after $. |
| 382 | dollar = string.rfind('$') |
| 383 | if dollar > 0: # Ignore $ in first character |
| 384 | link_text = string[dollar + 1:] |
| 385 | string = string[:dollar] |
| 386 | manual_link_text = True |
| 387 | else: |
| 388 | link_text = string |
| 389 | manual_link_text = False |
| 390 | |
| 391 | # Handle different types of references. |
| 392 | if string.startswith('$'): # Doc reference |
| 393 | return self._doc_link(string, link_text, manual_link_text, |
| 394 | relative_path_to_root) |
| 395 | |
| 396 | elif string.startswith('tensorflow::'): |
| 397 | # C++ symbol |
| 398 | return self._cc_link(string, link_text, manual_link_text, |
| 399 | relative_path_to_root) |
| 400 | |
| 401 | else: |
| 402 | is_python = False |
| 403 | for py_module_name in self._py_module_names: |
| 404 | if string == py_module_name or string.startswith(py_module_name + '.'): |
| 405 | is_python = True |
| 406 | break |
| 407 | if is_python: # Python symbol |
| 408 | return self.python_link( |
| 409 | link_text, |
| 410 | string, |
| 411 | relative_path_to_root, |
| 412 | code_ref=not manual_link_text) |
| 413 | |
| 414 | # Error! |
| 415 | raise TFDocsError('Did not understand "%s"' % match.group(0), |
| 416 | 'BROKEN_LINK') |
| 417 | |
| 418 | def _doc_link(self, string, link_text, manual_link_text, |
| 419 | relative_path_to_root): |
no test coverage detected