How to use the docutils.nodes.reference function in docutils

To help you get started, we’ve selected a few docutils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bitprophet / releases / tests / changelog.py View on Github external
def dashed_issues_appear_as_unlinked_issues(self):
        node = self._generate('1.0.2', _issue('bug', '-'))
        assert not isinstance(node[0][2], reference)
github sparkslabs / kamaelia / Sketches / MH / DocGen / DocExtractor.py View on Github external
findName=moduleName[len(self.config.docroot+"."):]
                module=self.config.repository.find(findName)
                try:
                    className=module.locate(base)
                except ValueError:
                    continue
                
                # work out which methods haven't been already overriden
                methodList = []
                for (name,method) in base.listAllFunctions():
                    if name not in overrides:
                        overrides.append(name)
                        uri = self.renderer.makeURI(moduleName,"symbol-"+className+"."+name)
                        methodList.append(nodes.list_item('',
                            nodes.paragraph('','',
                                nodes.reference('', nodes.Text(name), refuri=uri),
                                nodes.Text("(" + method.argString + ")"),
                                ),
                            )
                        )

                if len(methodList)>0:
                    docTree.append( nodes.section('',
                        nodes.title('', "Methods inherited from "+moduleName+"."+className+" :"),
                        nodes.bullet_list('', *methodList),
                        )
                    )

                        
        return docTree
github sphinx-contrib / httpdomain / sphinxcontrib / httpdomain.py View on Github external
def result_nodes(self, document, env, node, is_ref):
        method = node[0][0].lower()
        rawsource = node[0].rawsource
        config = env.domains['http'].env.config
        if method not in METHOD_REFS:
            if not config['http_strict_mode']:
                return [nodes.emphasis(method, method)], []
            reporter = document.reporter
            msg = reporter.error('%s is not valid HTTP method' % method,
                                 line=node.line)
            prb = nodes.problematic(method, method)
            return [prb], [msg]
        url = str(METHOD_REFS[method])
        if not url:
            return [nodes.emphasis(method, method)], []
        node = nodes.reference(rawsource, method.upper(), refuri=url)
        return [node], []
github sphinx-doc / sphinx / sphinx / environment / adapters / toctree.py View on Github external
def _entries_from_toctree(toctreenode: addnodes.toctree, parents: List[str],
                                  separate: bool = False, subtree: bool = False
                                  ) -> List[Element]:
            """Return TOC entries for a toctree node."""
            refs = [(e[0], e[1]) for e in toctreenode['entries']]
            entries = []  # type: List[Element]
            for (title, ref) in refs:
                try:
                    refdoc = None
                    if url_re.match(ref):
                        if title is None:
                            title = ref
                        reference = nodes.reference('', '', internal=False,
                                                    refuri=ref, anchorname='',
                                                    *[nodes.Text(title)])
                        para = addnodes.compact_paragraph('', '', reference)
                        item = nodes.list_item('', para)
                        toc = nodes.bullet_list('', item)
                    elif ref == 'self':
                        # 'self' refers to the document from which this
                        # toctree originates
                        ref = toctreenode['parent']
                        if not title:
                            title = clean_astext(self.env.titles[ref])
                        reference = nodes.reference('', '', internal=True,
                                                    refuri=ref,
                                                    anchorname='',
                                                    *[nodes.Text(title)])
                        para = addnodes.compact_paragraph('', '', reference)
github jmwright / cadquery-freecad-module / Libs / docutils / transforms / references.py View on Github external
def make_target_footnote(self, refuri, refs, notes):
        if refuri in notes:  # duplicate?
            footnote = notes[refuri]
            assert len(footnote['names']) == 1
            footnote_name = footnote['names'][0]
        else:                           # original
            footnote = nodes.footnote()
            footnote_id = self.document.set_id(footnote)
            # Use uppercase letters and a colon; they can't be
            # produced inside names by the parser.
            footnote_name = 'TARGET_NOTE: ' + footnote_id
            footnote['auto'] = 1
            footnote['names'] = [footnote_name]
            footnote_paragraph = nodes.paragraph()
            footnote_paragraph += nodes.reference('', refuri, refuri=refuri)
            footnote += footnote_paragraph
            self.document.note_autofootnote(footnote)
            self.document.note_explicit_target(footnote, footnote)
        for ref in refs:
            if isinstance(ref, nodes.target):
                continue
            refnode = nodes.footnote_reference(refname=footnote_name, auto=1)
            refnode['classes'] += self.classes
            self.document.note_autofootnote_ref(refnode)
            self.document.note_footnote_ref(refnode)
            index = ref.parent.index(ref) + 1
            reflist = [refnode]
            if not utils.get_trim_footnote_ref_space(self.document.settings):
                if self.classes:
                    reflist.insert(0, nodes.inline(text=' ', Classes=self.classes))
                else:
github numpy / numpydoc / numpydoc / linkcode.py View on Github external
if not info:
                continue

            # Call user code to resolve the link
            uri = resolve_target(domain, info)
            if not uri:
                # no source
                continue

            if uri in uris or not uri:
                # only one link per name, please
                continue
            uris.add(uri)

            onlynode = addnodes.only(expr='html')
            onlynode += nodes.reference('', '', internal=False, refuri=uri)
            onlynode[0] += nodes.inline('', _('[source]'),
                                        classes=['viewcode-link'])
            signode += onlynode
github Bcfg2 / bcfg2 / doc / exts / xmlschema.py View on Github external
def get_datatype_ref(title, target, baseurl):
    return build_node(nodes.reference('', '', refuri=baseurl % target),
                      nodes.literal(title, title))
github mongodb / mongo-c-driver / homepage-config / conf.py View on Github external
if text == "mongoc":
        lib = "mongo-c-driver"
    elif text == "bson":
        lib = "libbson"
    else:
        raise ValueError(
            "download link must be mongoc or libbson, not \"%s\"" % text)

    title = "%s-%s.tar.gz" % (lib, version)
    url = ("https://github.com/mongodb/%(lib)s/"
           "releases/download/%(version)s/%(lib)s-%(version)s.tar.gz") % {
              "lib": lib,
              "version": version
          }

    pnode = nodes.reference(title, title, internal=False, refuri=url)
    return [pnode], []
github kovidgoyal / kitty / docs / conf.py View on Github external
def link_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
    m = re.match(r'(.+)\s+<(.+?)>', text)
    if m is None:
        msg = inliner.reporter.error(f'link "{text}" not recognized', line=lineno)
        prb = inliner.problematic(rawtext, rawtext, msg)
        return [prb], [msg]
    text, url = m.group(1, 2)
    set_classes(options)
    node = nodes.reference(rawtext, text, refuri=url, **options)
    return [node], []
github sagemath / sagelib / doc / common / conf.py View on Github external
matches =  builder.env.domains['py'].find_obj(
        builder.env, module, cls, newtarget, reftype, searchmode)
    if not matches:
        debug_inf(app, "?? no matching doc for %s"%newtarget)
        return call_intersphinx(app, env, node, contnode)
    elif len(matches) > 1:
        env.warn(target_module,
                 'more than one target found for cross-reference '
                 '%r: %s' % (newtarget,
                             ', '.join(match[0] for match in matches)),
                 node.line)
    name, obj = matches[0]
    debug_inf(app, "++ match = %s %s"%(name, obj))

    from docutils import nodes
    newnode = nodes.reference('', '', internal=True)
    if name == target_module:
        newnode['refid'] = name
    else:
        newnode['refuri'] = builder.get_relative_uri(node['refdoc'], obj[0])
        newnode['refuri'] += '#' + name
        debug_inf(app, "++ DONE at URI %s"%(newnode['refuri']))
    newnode['reftitle'] = name
    newnode.append(contnode)
    return newnode