Exemplo n.º 1
0
Arquivo: sphinx.py Projeto: Janno/coq
    def visitAtomic(self, ctx:TacticNotationsParser.AtomicContext):
        atom = ctx.ATOM().getText()
        sub = ctx.SUB()
        node = nodes.inline(atom, atom)

        if sub:
            sub_index = sub.getText()[2:]
            node += nodes.subscript(sub_index, sub_index)

        return [node]
Exemplo n.º 2
0
Arquivo: sphinx.py Projeto: Janno/coq
    def visitHole(self, ctx:TacticNotationsParser.HoleContext):
        hole = ctx.ID().getText()
        token_name = hole[1:]
        node = nodes.inline(hole, token_name, classes=["hole"])

        sub = ctx.SUB()
        if sub:
            sub_index = sub.getText()[2:]
            node += nodes.subscript(sub_index, sub_index)

        return [addnodes.pending_xref(token_name, node, reftype='token', refdomain='std', reftarget=token_name)]
Exemplo n.º 3
0
def mol_role(role, rawtext, text, lineno, inliner, options={}, content=[]):
    n = []
    t = ''
    while text:
        if text[0] == '_':
            n.append(nodes.Text(t))
            t = ''
            n.append(nodes.subscript(text=text[1]))
            text = text[2:]
        else:
            t += text[0]
            text = text[1:]
    n.append(nodes.Text(t))
    return n, []
Exemplo n.º 4
0
def latex_to_nodes(text):
  """
  Convert '_{}' and '^{}' text to node representation.
  TODO: This doesn't work yet
  """
  return nodes.inline(text, text)
  m = SUBSUP_RE.findall(text)
  if m:
    n += latex_to_nodes(m[0][0])
    if m[0][1] == '^':
      n += nodes.superscript(latex_to_nodes(m[0][2]))
    elif m[0][1] == '_':
      n += nodes.subscript(latex_to_nodes(m[0][2]))
  else:
    n = nodes.inline(text, text)
  return n
Exemplo n.º 5
0
def latex_to_nodes(text):
    """
  Convert '_{}' and '^{}' text to node representation.
  TODO: This doesn't work yet
  """
    return nodes.inline(text, text)
    m = SUBSUP_RE.findall(text)
    if m:
        n += latex_to_nodes(m[0][0])
        if m[0][1] == '^':
            n += nodes.superscript(latex_to_nodes(m[0][2]))
        elif m[0][1] == '_':
            n += nodes.subscript(latex_to_nodes(m[0][2]))
    else:
        n = nodes.inline(text, text)
    return n
Exemplo n.º 6
0
    def visitHole(self, ctx: TacticNotationsParser.HoleContext):
        hole = ctx.ID().getText()
        token_name = hole[1:]
        node = nodes.inline(hole, token_name, classes=["hole"])

        sub = ctx.SUB()
        if sub:
            sub_index = sub.getText()[2:]
            node += nodes.subscript(sub_index, sub_index)

        return [
            addnodes.pending_xref(token_name,
                                  node,
                                  reftype='token',
                                  refdomain='std',
                                  reftarget=token_name)
        ]
Exemplo n.º 7
0
def mol_role(role, rawtext, text, lineno, inliner, options={}, content=[]):
    n = []
    t = ''
    while text:
        if text[0] == '_':
            n.append(nodes.inline(text=t))
            t = ''
            m = re.match(r'\d+', text[1:])
            if m is None:
                raise RuntimeError('Expected one or more digits after "_"')
            digits = m.group()
            n.append(nodes.subscript(text=digits))
            text = text[1 + len(digits):]
        else:
            t += text[0]
            text = text[1:]
    n.append(nodes.inline(text=t))
    return n, []
Exemplo n.º 8
0
    def format_response_class(self, response_class_name):
        ret = n.container()
        ret += addnodes.desc_returns(text=response_class_name)
        model = self.models.get(response_class_name)
        props = addnodes.desc_parameterlist()
        for key, property in model['properties'].items():
            pc = n.container()
            if property['required']:
                pc += addnodes.desc_parameter(key, key)
            else:
                pc += addnodes.desc_optional(key, key)

            pc += n.strong(text=' type: %s ' % property['type'])
            allowableValues = property.get('allowableValues')
            if allowableValues:
                allowableValues.pop('valueType', None)
                pc += n.subscript(text=' %s' % allowableValues)

            props += pc
        ret += props
        return ret
Exemplo n.º 9
0
    def format_response_class(self, response_class_name):
        ret = n.container()
        ret += addnodes.desc_returns(text=response_class_name)
        model = self.models.get(response_class_name)
        props = addnodes.desc_parameterlist()
        for key, property in model["properties"].items():
            pc = n.container()
            if property["required"]:
                pc += addnodes.desc_parameter(key, key)
            else:
                pc += addnodes.desc_optional(key, key)

            pc += n.strong(text=" type: %s " % property["type"])
            allowableValues = property.get("allowableValues")
            if allowableValues:
                allowableValues.pop("valueType", None)
                pc += n.subscript(text=" %s" % allowableValues)

            props += pc
        ret += props
        return ret
Exemplo n.º 10
0
    def format_response_class(self, response_class_name):
        ret = n.container()
        ret += addnodes.desc_returns(text=response_class_name)
        model = self.models.get(response_class_name)
        props = addnodes.desc_parameterlist()
        for key, property in model['properties'].items():
            pc = n.container()
            if property['required']:
                pc += addnodes.desc_parameter(key, key)
            else:
                pc += addnodes.desc_optional(key, key)


            pc += n.strong(text=' type: %s ' % property['type'])
            allowableValues = property.get('allowableValues')
            if allowableValues:
                allowableValues.pop('valueType', None)
                pc += n.subscript(text=' %s' % allowableValues)

            props += pc
        ret += props
        return ret
Exemplo n.º 11
0
Arquivo: xroles.py Projeto: xcore/xdoc
def subscript(role, rawtext, text, lineno, inliner, options={}, content={}):
    sub = nodes.subscript()
    sub += miniparse(text)
    return [sub],[]