Esempio n. 1
0
    def run(self):
        if self.is_seealso:
            ret = make_admonition(addnodes.seealso, self.name, [_('See')],
                                  self.options, self.content, self.lineno,
                                  self.content_offset, self.block_text,
                                  self.state, self.state_machine)
        elif self.is_related:
            ret = make_admonition(addnodes.seealso, self.name, [_('Related')],
                                  self.options, self.content, self.lineno,
                                  self.content_offset, self.block_text,
                                  self.state, self.state_machine)
        else:
            ret = make_admonition(optional_node, self.name,
                                  self.directive_name, self.options,
                                  self.content, self.lineno,
                                  self.content_offset, self.block_text,
                                  self.state, self.state_machine)

        if self.arguments:
            argnodes, msgs = self.state.inline_text(self.arguments[0],
                                                    self.lineno)
            para = nodes.paragraph()
            para += argnodes
            para += msgs
            ret[0].insert(1, para)
        return ret
Esempio n. 2
0
 def run(self):
     ad = make_admonition(youcanhelp_node, self.name, ["You Can Help!"],
                          self.options, self.content, self.lineno,
                          self.content_offset, self.block_text, self.state,
                          self.state_machine)
     ad[0].line = self.lineno
     return ad
Esempio n. 3
0
   def run(self):
      # noinspection PyUnresolvedReferences
      """ run
      :return:
      """
      ret = make_admonition(
         self.node_class,
         self.name,
         [self.label],
         self.options,
         self.content,
         self.lineno,
         self.content_offset,
         self.block_text,
         self.state,
         self.state_machine
      )

      if self.arguments:
         argnodes, msgs = self.state.inline_text(self.arguments[0], self.lineno)
         para = nodes.paragraph()
         para += argnodes
         para += msgs
         ret[0].insert(1, para)

      return ret
Esempio n. 4
0
    def run(self):
        ret = make_admonition(related_node, self.name, [_('Related')],
                              self.options, self.content, self.lineno,
                              self.content_offset, self.block_text, self.state,
                              self.state_machine)

        return self.return_node(ret)
Esempio n. 5
0
    def run(self):
        env = self.state.document.settings.env
        targetid = "tag-%d" % env.new_serialno('tag')
        targetnode = nodes.target('', '', ids=[targetid])

        #the tags fetched from the custom directive are one piece of text
        #sitting in self.content[0]
        taggs = self.content[0].split(", ")
        links = []

        for tagg in taggs:
            #create rst hyperlinks of format `Python <http://www.python.org/>`_.
            link = "`" + tagg  +" <../tags/" + tagg + ".html>`_ "
            links.append(link)
        #put links back in a single comma-separated string together
        linkjoin = ", ".join(links)

        #replace content[0] with hyperlinks to display in admonition
        self.content[0] = linkjoin

        ad = make_admonition(tag, self.name, [_('Tags')], self.options,
                             self.content, self.lineno, self.content_offset,
                             self.block_text, self.state, self.state_machine)

        return [targetnode] + ad
Esempio n. 6
0
 def run(self):
     nodes = make_admonition(extension_node,
             self.name, [_('DB API extension')], self.options,
             self.content, self.lineno, self.content_offset,
             self.block_text, self.state, self.state_machine)
     nodes[0]['classes'].append('dbapi-extension')
     return nodes
    def run(self):
        if len(self.content) == 0:
            # TODO: raise nice error that something is missing
            return

        string_vars = {
            'uid': self.content[0],
            'width': 480,
            'height': 300,
            'allowscriptaccess': 'allways',
            'allowfullscreen': 'true', }

        # TODO: need to redo this
        #for item in self.content[1:]:
        #    item = item.split('=')
        #    if len(item) == 2:
        #        key, value = item[0].strip(), item[1].strip()
        #        if key in string_vars.keys():
        #            string_vars[key] = value

        env = self.state.document.settings.env
        targetid = "bliptv-%d" % env.new_serialno('embed')
        targetnode = nodes.target('', '', ids=[targetid])

        ad = make_admonition(embed, self.name, ['Todo'], self.options,
                             self.content, self.lineno, self.content_offset,
                             self.block_text, self.state, self.state_machine)

        return [targetnode] + ad
    def run(self):
        env = self.state.document.settings.env
        targetid = "%s-%d" % (self.requirement_class,
                              env.new_serialno(self.requirement_class))
        targetnode = nodes.target('', '', ids=[targetid])

        # BUG? why is it always mandatory?
        # maybe select node type per self.requirement_class
        ad = make_admonition(mandatory, self.name, [_(self.label)],
                             self.options, self.content, self.lineno,
                             self.content_offset, self.block_text, self.state,
                             self.state_machine)

        env_data_name = "rfc2119_all_%s" % self.requirement_class
        if not hasattr(env, env_data_name):
            exec("env.%s = []" % env_data_name)

        env_data = eval("env.%s" % env_data_name)
        env_data.append({
            'docname': env.docname,
            'lineno': self.lineno,
            'rfc2119': ad[0].deepcopy(),
            'target': targetnode
        })

        return [targetnode] + ad
Esempio n. 9
0
    def run(self):
        env = self.state.document.settings.env

        # create a new target node for linking to
        targetid = "todo-%d" % env.new_serialno("todo")
        targetnode = nodes.target("", "", ids=[targetid])

        # make the admonition node
        ad = make_admonition(
            Todo,
            self.name,
            [("Todo")],
            self.options,
            self.content,
            self.lineno,
            self.content_offset,
            self.block_text,
            self.state,
            self.state_machine,
        )

        # store a handle in a global list of all todos
        if not hasattr(env, "todo_all_todos"):
            env.todo_all_todos = []
        env.todo_all_todos.append(
            {"docname": env.docname, "lineno": self.lineno, "todo": ad[0].deepcopy(), "target": targetnode}
        )

        # return both the linking target and the node itself
        return [targetnode] + ad
Esempio n. 10
0
    def run(self):
        env = self.state.document.settings.env

        targetid = "req-%d" % env.new_serialno('req')
        targetnode = nodes.target('', '', ids=[targetid])

        ad = make_admonition(req, self.name, [_('Requirement coverage')],
                             self.options, self.content, self.lineno,
                             self.content_offset, self.block_text, self.state,
                             self.state_machine)

        if not hasattr(env, 'req_all_reqs'):
            env.req_all_reqs = []

        env.req_all_reqs.append({
            'docname': env.docname,
            'evidence': '\n'.join(self.content[-1:]),
            'section': find_parent_section_name(self.state),
            'reqid': self.content[0],
            'req': ad[0].deepcopy(),
            'target': targetnode,
        })

        if not self.options.has_key('show'):
            return [targetnode]

        return [targetnode] + ad
Esempio n. 11
0
    def run(self):
        ret = make_admonition(optional_node, self.name, self.directive_name,
                              self.options, self.content, self.lineno,
                              self.content_offset, self.block_text, self.state,
                              self.state_machine)

        return self.return_node(ret)
Esempio n. 12
0
 def _make_admonition(self, title="Task"):
     ad = make_admonition(task, self.name, [title], self.options,
                          self.content, self.lineno, self.content_offset,
                          self.block_text, self.state, self.state_machine)
     self.add_name(ad[0])
     #print(title, ad)
     return ad
Esempio n. 13
0
    def run(self):
        env = self.state.document.settings.env

        targetid = "req-%d" % env.new_serialno('req')
        targetnode = nodes.target('', '', ids=[targetid])

        ad = make_admonition(req, self.name, [_('Requirement coverage')], self.options,
                             self.content, self.lineno, self.content_offset,
                             self.block_text, self.state, self.state_machine)

        if not hasattr(env, 'req_all_reqs'):
            env.req_all_reqs = []

        

        env.req_all_reqs.append({
            'docname': env.docname,
            'evidence': '\n'.join(self.content[-1:]),
            'section' : find_parent_section_name(self.state),
            'reqid' : self.content[0],
            'req': ad[0].deepcopy(),
            'target': targetnode,
        })

        if not self.options.has_key('show'):
            return [targetnode]

        return [targetnode] + ad
Esempio n. 14
0
    def run(self):
        env = self.state.document.settings.env
        targetid = "sphinxreportwarning-%s" % env.new_serialno( 'sphinxreportwarning' )
        # env.index_num += 1
        targetnode = nodes.target('', '', ids=[targetid])

        # this sets the formatting
        self.options["class"] = "critical"

        if len(self.arguments) > 0:
            warningclass = self.arguments[0]
        else:
            warningclass = "generic"

        ad = make_admonition(sphinxreportwarning_node, 
                             self.name, 
                             [_('SphinxreportWarning')],
                             self.options,
                             self.content, self.lineno, self.content_offset,
                             self.block_text, self.state, self.state_machine)

        # Attach a list of all sphinxreportwarnings to the environment,
        # the sphinxreportwarninglist works with the collected sphinxreportwarning nodes
        if not hasattr(env, 'sphinxreportwarning_all_sphinxreportwarnings'):
            env.sphinxreportwarning_all_sphinxreportwarnings = []
        env.sphinxreportwarning_all_sphinxreportwarnings.append({
            'docname': env.docname,
            'lineno': self.lineno,
            'sphinxreportwarning': ad[0].deepcopy(),
            'warningclass' : warningclass,
            'target': targetnode,
        })

        return [targetnode] + ad
Esempio n. 15
0
    def run(self):
        env = self.state.document.settings.env
        ad = make_admonition(newinxc, self.name, [], self.options,
                             self.content, self.lineno, self.content_offset,
                             self.block_text, self.state, self.state_machine)


        return ad
    def run(self):
        env = self.state.document.settings.env

        return make_admonition(mongodoc, self.name,
                               ['See general MongoDB documentation'],
                               self.options, self.content, self.lineno,
                               self.content_offset, self.block_text,
                               self.state, self.state_machine)
Esempio n. 17
0
    def run(self):
        env = self.state.document.settings.env

        return make_admonition(mongodoc, self.name,
                               ['See general MongoDB documentation'],
                               self.options, self.content, self.lineno,
                               self.content_offset, self.block_text,
                               self.state, self.state_machine)
    def run(self):
        message = IMPORT_MESSAGE.format(module=self.content[0])

        ad = make_admonition(ImportFrom, self.name, [], self.options,
                             nodes.paragraph("", message), self.lineno,
                             self.content_offset, self.block_text, self.state,
                             self.state_machine)
        ad[0].line = self.lineno
        return ad
Esempio n. 19
0
    def run(self):

        ad = make_admonition(UpdateNode, self.name, [_('Updated on')],
                             self.options,
                             self.content, self.lineno, self.content_offset,
                             self.block_text, self.state, self.state_machine)
        ad[0]['date'] = self.arguments[0] if self.arguments else ''
        set_source_info(self, ad[0])
        return ad
    def run(self):
        if self.is_seealso:
            ret = make_admonition(addnodes.seealso, self.name, [_('See')], self.options,
                                  self.content, self.lineno, self.content_offset, self.block_text,
                                  self.state, self.state_machine)
        else:
            ret = make_admonition(optional_node, self.name, self.directive_name, self.options,
                                  self.content, self.lineno, self.content_offset,
                                  self.block_text, self.state, self.state_machine)

        if self.arguments:
            argnodes, msgs = self.state.inline_text(self.arguments[0],
                                                    self.lineno)
            para = nodes.paragraph()
            para += argnodes
            para += msgs
            ret[0].insert(1, para)
        return ret
Esempio n. 21
0
    def run(self):

        ad = make_admonition(UpdateNode, self.name, [_('Updated on')],
                             self.options, self.content, self.lineno,
                             self.content_offset, self.block_text, self.state,
                             self.state_machine)
        ad[0]['date'] = self.arguments[0] if self.arguments else ''
        set_source_info(self, ad[0])
        return ad
Esempio n. 22
0
    def run(self):
        env = self.state.document.settings.env
        targetid = 'index-%s' % env.new_serialno('index')
        targetnode = nodes.target('', '', ids=[targetid])

        ad = make_admonition(todo_node, self.name, [_('Todo')], self.options,
                             self.content, self.lineno, self.content_offset,
                             self.block_text, self.state, self.state_machine)
        set_source_info(self, ad[0])
        return [targetnode] + ad
Esempio n. 23
0
    def run(self):
        env = self.state.document.settings.env
        targetid = 'index-%s' % env.new_serialno('index')
        targetnode = nodes.target('', '', ids=[targetid])

        ad = make_admonition(todo_node, self.name, [_('Todo')], self.options,
                             self.content, self.lineno, self.content_offset,
                             self.block_text, self.state, self.state_machine)
        set_source_info(self, ad[0])
        return [targetnode] + ad
Esempio n. 24
0
    def run(self):
        env = self.state.document.settings.env

        targetid = "tip-%d" % (env.new_serialno('tip'))
        targetnode = nodes.target('', '', ids=[targetid])

        ad = make_admonition(tip_node, self.name, [_('Tip')], self.options,
                             self.content, self.lineno, self.content_offset,
                             self.block_text, self.state, self.state_machine)

        return [targetnode] + ad
Esempio n. 25
0
    def run(self):
        env = self.state.document.settings.env

        targetid = 'question-%d' % env.new_serialno('question')
        targetnode = nodes.target('', '', ids=[targetid])

        self.options['class'] = ['question']
        ad = make_admonition(question, self.name, ['Question'], self.options,
                             self.content, self.lineno, self.content_offset,
                             self.block_text, self.state, self.state_machine)
        return [targetnode] + ad
Esempio n. 26
0
File: yippie.py Progetto: rlr/fjord
    def run(self):
        env = self.state.document.settings.env

        targetid = 'yippie-%d' % env.new_serialno('yippie')
        targetnode = nodes.target('', '', ids=[targetid])

        ad = make_admonition(yippie_node, self.name, [_('Yippie')], self.options,
                             self.content, self.lineno, self.content_offset,
                             self.block_text, self.state, self.state_machine)

        return [targetnode] + ad
Esempio n. 27
0
    def run(self):
        env = self.state.document.settings.env

        targetid = "req-%d" % env.new_serialno('req')
        targetnode = nodes.target('', '', ids=[targetid])
        sectionnode = find_parent_section_name(self.state)
        includead = True

        ads = []
        ad = None

        if sectionnode : 
            ads = sectionnode.traverse(nodes.Admonition)
        
        if len(ads) > 0 :
            ad = ads[0] 
            #pprint(ad)
            para = ad.traverse(nodes.paragraph, descend=True)
            para[0] += nodes.Text(', ' + self.content[0])   
#            pprint(para[0])
            includead = False
        else :
            #pprint(self.content)
            text = nodes.paragraph()
            text += nodes.Text("This section covers ")
            text += nodes.Text(self.content[0])
            ad = make_admonition(req, self.name, [_('Requirement coverage')], self.options,
                             text, self.lineno, self.content_offset,
                             self.block_text, self.state, self.state_machine)
            #pprint(ad)


        if not hasattr(env, 'req_all_reqs'):
            env.req_all_reqs = []

        

        env.req_all_reqs.append({
            'docname': env.docname,
            'evidence': '\n'.join(self.content[-1:]),
            'section' : sectionnode,
            'reqid' : self.content[0],
            'req': ad[0].deepcopy(),
            'target': targetnode,
        })

        if not includead:
            return [targetnode]

        if not 'show' in self.options:
            return [targetnode]

        #pprint("return all")
        return [targetnode] + ad
Esempio n. 28
0
 def run(self):
     ad = make_admonition(self.name, ['Autopilot Says'], self.options,
                          self.content, self.lineno, self.content_offset,
                          self.block_text, self.state, self.state_machine)
     #image_container = nodes.container()
     #image_container.append(nodes.image(uri='/images/otto-64.png'))
     #image_container['classes'] = ['otto-image-container']
     #outer_container = nodes.container()
     #outer_container.extend([image_container, ad])
     #outer_container['classes'] = ['otto-says-container']
     return [ad]
Esempio n. 29
0
File: post.py Progetto: marble/ablog
    def run(self):

        ad = make_admonition(UpdateNode, self.name, [_('Updated on')],
                             self.options,
                             self.content, self.lineno, self.content_offset,
                             self.block_text, self.state, self.state_machine)
            #date = datetime.strptime(date, app.config['post_date_format'])
        ad[0]['date'] = self.arguments[0] if self.arguments else ''

        set_source_info(self, ad[0])
        return ad
Esempio n. 30
0
    def run(self):
        message = DANGER_MESSAGE
        if self.content:
            message += DANGER_ALTERNATE.format(alternate=self.content[0])

        ad = make_admonition(Hazmat, self.name, [], self.options,
                             nodes.paragraph("", message), self.lineno,
                             self.content_offset, self.block_text, self.state,
                             self.state_machine)
        ad[0].line = self.lineno
        return ad
Esempio n. 31
0
 def run(self):
     env = self.state.document.settings.env
     link = env.docname.replace('\\', '_') + '.html'
     self.content = statemachine.StringList([SNIPTEXT % link])
     targetid = "codesnippet-%d" % env.new_serialno('codesnippet')
     targetnode = nodes.target('', '', ids=[targetid])
     ad = make_admonition(CodeSnippet, self.name, ['CodeSnippet'],
                          self.options, self.content, self.lineno,
                          self.content_offset, self.block_text, self.state,
                          self.state_machine)
     return [targetnode] + ad
Esempio n. 32
0
    def run(self):

        ad = make_admonition(UpdateNode, self.name, [_('Updated on')],
                             self.options, self.content, self.lineno,
                             self.content_offset, self.block_text, self.state,
                             self.state_machine)
        #date = datetime.strptime(date, app.config['post_date_format'])
        ad[0]['date'] = self.arguments[0] if self.arguments else ''

        set_source_info(self, ad[0])
        return ad
Esempio n. 33
0
    def run(self):
        lines = (
            """The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119.""",
        )
        boilerplate = statemachine.ViewList(initlist=lines)
        self.content.append(boilerplate)

        return make_admonition(rfc2119interpretation, self.name,
                               [_('RFC 2119 keywords')], self.options,
                               self.content, self.lineno, self.content_offset,
                               self.block_text, self.state, self.state_machine)
Esempio n. 34
0
    def run(self):
        self.arguments = ['instructor']

        ret = make_admonition(instructor_node, self.name, [_('Instructor Note')],
                              self.options, self.content, self.lineno, self.content_offset,
                              self.block_text, self.state, self.state_machine)

        ret[0]['expr'] = self.arguments[0]
        ret[0]['classes'] += 'note'

        return ret
 def run(self):
     ret = make_admonition(exercise, self.name, ['Exercise'], self.options,
                           self.content, self.lineno, self.content_offset,
                           self.block_text, self.state, self.state_machine)
     if self.arguments:
         argnodes, msgs = self.state.inline_text(self.arguments[0],
                                                 self.lineno)
         para = nodes.paragraph()
         para += argnodes
         para += msgs
         ret[0].insert(1, para)
     return ret
Esempio n. 36
0
def seealso_directive(name, arguments, options, content, lineno,
                      content_offset, block_text, state, state_machine):
    ret = make_admonition(
        addnodes.seealso, name, [_('See also')], options, content,
        lineno, content_offset, block_text, state, state_machine)
    if arguments:
        argnodes, msgs = state.inline_text(arguments[0], lineno)
        para = nodes.paragraph()
        para += argnodes
        para += msgs
        ret[0].insert(1, para)
    return ret
Esempio n. 37
0
def seealso_directive(name, arguments, options, content, lineno,
                      content_offset, block_text, state, state_machine):
    ret = make_admonition(
        addnodes.seealso, name, [_('See also')], options, content,
        lineno, content_offset, block_text, state, state_machine)
    if arguments:
        argnodes, msgs = state.inline_text(arguments[0], lineno)
        para = nodes.paragraph()
        para += argnodes
        para += msgs
        ret[0].insert(1, para)
    return ret
Esempio n. 38
0
 def run(self):
     ret = make_admonition(optional_node, self.name, [_('Optional')], self.options,
                          self.content, self.lineno, self.content_offset,
                          self.block_text, self.state, self.state_machine)
     if self.arguments:
         argnodes, msgs = self.state.inline_text(self.arguments[0],
                                                 self.lineno)
         para = nodes.paragraph()
         para += argnodes
         para += msgs
         ret[0].insert(1, para)
     return ret
Esempio n. 39
0
    def run(self):
        env = self.state.document.settings.env

        targetid = "req-%d" % env.new_serialno('req')
        targetnode = nodes.target('', '', ids=[targetid])
        sectionnode = find_parent_section_name(self.state)
        includead = True

        ads = []
        ad = None

        if sectionnode:
            ads = sectionnode.traverse(nodes.Admonition)

        if len(ads) > 0:
            ad = ads[0]
            #pprint(ad)
            para = ad.traverse(nodes.paragraph, descend=True)
            para[0] += nodes.Text(', ' + self.content[0])
            #            pprint(para[0])
            includead = False
        else:
            #pprint(self.content)
            text = nodes.paragraph()
            text += nodes.Text("This section covers ")
            text += nodes.Text(self.content[0])
            ad = make_admonition(req, self.name, [_('Requirement coverage')],
                                 self.options, text, self.lineno,
                                 self.content_offset, self.block_text,
                                 self.state, self.state_machine)
            #pprint(ad)

        if not hasattr(env, 'req_all_reqs'):
            env.req_all_reqs = []

        env.req_all_reqs.append({
            'docname': env.docname,
            'evidence': '\n'.join(self.content[-1:]),
            'section': sectionnode,
            'reqid': self.content[0],
            'req': ad[0].deepcopy(),
            'target': targetnode,
        })

        if not includead:
            return [targetnode]

        if not 'show' in self.options:
            return [targetnode]

        #pprint("return all")
        return [targetnode] + ad
Esempio n. 40
0
    def plot_directive(name, arguments, options, content, lineno,
                       content_offset, block_text, state, state_machine):
        env = state.document.settings.env

        targetid = "plot-%d" % env.new_serialno('plot')
        targetnode = nodes.target('', '', ids=[targetid])

        ad = make_admonition(missing_plot, name,
                             [_('Install matplotlib to render this plot')],
                             options, content, lineno, content_offset,
                             block_text, state, state_machine)

        return [targetnode] + ad
 def run(self):
     ad = make_admonition(
         youcanhelp_node,
         self.name,
         ["You Can Help!"],
         self.options,
         self.content,
         self.lineno,
         self.content_offset,
         self.block_text,
         self.state,
         self.state_machine)
     ad[0].line = self.lineno
     return ad
    def run(self):
        title = u''
        if self.arguments:
            title += self.arguments[0]

        if 'class' in self.options:
            self.options['class'].append(self.css_class)
        else:
            self.options['class'] = [self.css_class]

        ret = make_admonition(node_class, self.name, [title], self.options,
                              self.content, self.lineno, self.content_offset,
                              self.block_text, self.state, self.state_machine)
        ret[0].attributes['name'] = self.name
        return ret
Esempio n. 43
0
    def run(self):
        ret = make_admonition(
            optional_node,
            self.name,
            self.directive_name,
            self.options,
            self.content,
            self.lineno,
            self.content_offset,
            self.block_text,
            self.state,
            self.state_machine,
        )

        return self.return_node(ret)
Esempio n. 44
0
    def run(self):
        ret = make_admonition(
            related_node,
            self.name,
            [_("Related")],
            self.options,
            self.content,
            self.lineno,
            self.content_offset,
            self.block_text,
            self.state,
            self.state_machine,
        )

        return self.return_node(ret)
Esempio n. 45
0
    def run(self):
        ad = make_admonition(reserved, self.name, [_('Reserved')],
                             self.options, self.content, self.lineno,
                             self.content_offset, self.block_text, self.state,
                             self.state_machine)

        if self.arguments:
            argnodes, msgs = self.state.inline_text(self.arguments[0],
                                                    self.lineno)
            para = nodes.paragraph()
            para += argnodes
            para += msgs
            ad[0].insert(1, para)

        return ad
Esempio n. 46
0
    def run(self):
        ''' Cette fonction doit retourner une liste de noeuds '''

        env = self.state.document.settings.env
        app = env.app

        res_nodes = []

        # ajouter l'admonition n�cessaire
        ad = make_admonition(sqlexplain, self.name, ['But de la requete'],
                             self.options, self.content, self.lineno,
                             self.content_offset, self.block_text, self.state,
                             self.state_machine)

        return ad
Esempio n. 47
0
 def run(self):
     ad = make_admonition(
         Hazmat,
         self.name,
         [],
         self.options,
         nodes.paragraph("", DANGER_MESSAGE),
         self.lineno,
         self.content_offset,
         self.block_text,
         self.state,
         self.state_machine
     )
     ad[0].line = self.lineno
     return ad
Esempio n. 48
0
    def run(self):
        ad = make_admonition(
            reserved, self.name, [_('Reserved')], self.options,
            self.content, self.lineno, self.content_offset, self.block_text,
            self.state, self.state_machine)

        if self.arguments:
            argnodes, msgs = self.state.inline_text(self.arguments[0],
                                                    self.lineno)
            para = nodes.paragraph()
            para += argnodes
            para += msgs
            ad[0].insert(1,para)

        return ad
Esempio n. 49
0
    def run(self):
        env = self.state.document.settings.env

        ad = make_admonition(spam, self.name, [SPAM], self.options,
                             self.content, self.lineno, self.content_offset,
                             self.block_text, self.state, self.state_machine)

        spams = getattr(env, 'spam_all_spams', [])
        spams.append({
            'docname': env.docname,
            'lineno': self.lineno,
            'spam': ad[0].deepcopy(),
        })
        print(spams)
        env.spam_all_spams = spams

        return ad
    def run(self):
        message = IMPORT_MESSAGE.format(module=self.content[0])

        ad = make_admonition(
            ImportFrom,
            self.name,
            [],
            self.options,
            nodes.paragraph("", message),
            self.lineno,
            self.content_offset,
            self.block_text,
            self.state,
            self.state_machine
        )
        ad[0].line = self.lineno
        return ad
Esempio n. 51
0
 def run(self):
     env = self.state.document.settings.env
     link = env.docname.replace("\\", "_") + ".html"
     self.content = statemachine.StringList([SNIPTEXT % link])
     targetid = "codesnippet-%d" % env.new_serialno("codesnippet")
     targetnode = nodes.target("", "", ids=[targetid])
     ad = make_admonition(
         CodeSnippet,
         self.name,
         ["CodeSnippet"],
         self.options,
         self.content,
         self.lineno,
         self.content_offset,
         self.block_text,
         self.state,
         self.state_machine,
     )
     return [targetnode] + ad
Esempio n. 52
0
    def run(self):
        message = DANGER_MESSAGE
        if self.content:
            message += DANGER_ALTERNATE.format(alternate=self.content[0])

        ad = make_admonition(
            Hazmat,
            self.name,
            [],
            self.options,
            nodes.paragraph("", message),
            self.lineno,
            self.content_offset,
            self.block_text,
            self.state,
            self.state_machine
        )
        ad[0].line = self.lineno
        return ad
Esempio n. 53
0
    def run(self):
        self.arguments = ["instructor"]

        ret = make_admonition(
            instructor_node,
            self.name,
            [_("Instructor")],
            self.options,
            self.content,
            self.lineno,
            self.content_offset,
            self.block_text,
            self.state,
            self.state_machine,
        )

        ret[0]["expr"] = self.arguments[0]
        ret[0]["classes"] += "note"

        return ret
Esempio n. 54
0
    def run(self):
        env = self.state.document.settings.env

        targetid = "citeulike-%d" % env.new_serialno('citeulike')
        targetnode = nodes.target('', '', ids=[targetid])

        ad = make_admonition(citeulike, self.name, [_('citeulike')], self.options,
                             self.content, self.lineno, self.content_offset,
                             self.block_text, self.state, self.state_machine)

        if not hasattr(env, 'citeulike_all_citeulikes'):
            env.citeulike_all_citeulikes = []
        env.citeulike_all_citeulikes.append({
            'docname': env.docname,
            'lineno': self.lineno,
            'citeulike': ad[0].deepcopy(),
            'target': targetnode,
        })

        return [targetnode] + ad
Esempio n. 55
0
   def run(self):
      # noinspection PyUnresolvedReferences
      """ run
      :return:
      """
      if self.code_block_highlighter_to_check not in self.block_text:
         raise Err('PSphinxExampleCheckedAdmonition.run', [
            'Did not find required code-block directive: <{}>'.format(self.code_block_highlighter_to_check),
            '',
            ' -------------------- block_text START --------------------',
            '',
            '',
            self.block_text,
            '',
            '',
            ' -------------------- block_text END --------------------'
            ])

      ret = make_admonition(
         self.node_class,
         self.name,
         [self.label],
         self.options,
         self.content,
         self.lineno,
         self.content_offset,
         self.block_text,
         self.state,
         self.state_machine
      )

      if self.arguments:
         argnodes, msgs = self.state.inline_text(self.arguments[0], self.lineno)
         para = nodes.paragraph()
         para += argnodes
         para += msgs
         ret[0].insert(1, para)

      return ret
Esempio n. 56
0
    def run(self):
        env = self.state.document.settings.env

        targetid = "todo-%s" % env.index_num
        env.index_num += 1
        targetnode = nodes.target('', '', ids=[targetid])

        ad = make_admonition(todo_node, self.name, [_('Todo')], self.options,
                             self.content, self.lineno, self.content_offset,
                             self.block_text, self.state, self.state_machine)

        # Attach a list of all todos to the environment,
        # the todolist works with the collected todo nodes
        if not hasattr(env, 'todo_all_todos'):
            env.todo_all_todos = []
        env.todo_all_todos.append({
            'docname': env.docname,
            'lineno': self.lineno,
            'todo': ad[0].deepcopy(),
            'target': targetnode,
        })

        return [targetnode] + ad