Exemple #1
0
def outline_tree(env, ol, outline, context, active, min_depth, max_depth):
    if min_depth > max_depth:
        min_depth, max_depth = max_depth, min_depth
    max_depth = min(6, max_depth)
    min_depth = max(1, min_depth)
    previous_depth = min_depth
    
    stack = [None] * (max_depth + 1)
    # stack of (<element for new sublists>, <element for new items>)
    stack[previous_depth] = (None, ol)
    
    for depth, anchor, heading in outline:
        if min_depth <= depth <= max_depth:
            for d in range(previous_depth, depth):
                li, ol = stack[d]
                if not li:
                    li = tag.li()
                    ol.append(li)
                    stack[d] = (li, ol)
                new_ol = tag.ol()
                li.append(new_ol)
                stack[d+1] = (None, new_ol)
            href = get_resource_url(env, context.resource, context.href)
            if href.endswith(context.req.path_info):
                href = ''
            href += '#' + anchor
            li, ol = stack[depth]
            li = tag.li(tag.a(Markup(heading), href=href),
                        class_=active and 'active' or None)
            ol.append(li)
            stack[depth] = (li, ol)
            previous_depth = depth
    return stack[min_depth][0]
Exemple #2
0
  def expand_macro(self,formatter,name,content):
    citelist = getattr(formatter, CITELIST,[])
    columns = ['itemTypeID','firstCreator','year', 'publicationTitle','volume','issue','pages','title','url']
    model = ZoteroModelProvider(self.env)
    item_ids = model.get_items_ids_by_keys( citelist )
    item_data = model.get_item_columns_by_iids(item_ids,columns)
    refs = []

    for itemID, itemTypeID, firstCreator, year, publicationTitle, volume, issue, pages, title, url in item_data:
        prefix = ''
        if firstCreator and firstCreator != 'None':
            prefix += firstCreator
        if year and year != 'None':
            prefix += ' ' + year + '. '
        titlehref = ''
        if title and title != 'None':
            titlehref = tag.a(title, href = formatter.req.href.zotero('item/' + str(itemID)))
        suffix = ''
        if publicationTitle and publicationTitle != 'None':
            suffix += '. ' + publicationTitle
        if volume and volume != 'None':
            suffix += ', ' + str(volume)
        if pages and pages != 'None':
            suffix += ': ' + pages + '.'
        ref = []
        if url and url != 'None':
            ref = tag.li( tag.span( prefix ), tag.span(titlehref), tag.span(suffix),
                    tag.br(),tag.span(tag.a(url, href=url ),style = 'font-size:x-small;') )
        else: 
            ref = tag.li( tag.span( prefix ), tag.span(titlehref), tag.span(suffix) )
    
        refs.append(ref)

    return tag.div(tag.ol(refs),id='References')
Exemple #3
0
def outline_tree(env, ol, outline, context, active, min_depth, max_depth):
    if min_depth > max_depth:
        min_depth, max_depth = max_depth, min_depth
    max_depth = min(6, max_depth)
    min_depth = max(1, min_depth)
    previous_depth = min_depth

    stack = [None] * (max_depth + 1)
    # stack of (<element for new sublists>, <element for new items>)
    stack[previous_depth] = (None, ol)

    for depth, anchor, heading in outline:
        if min_depth <= depth <= max_depth:
            for d in range(previous_depth, depth):
                li, ol = stack[d]
                if not li:
                    li = tag.li()
                    ol.append(li)
                    stack[d] = (li, ol)
                new_ol = tag.ol()
                li.append(new_ol)
                stack[d + 1] = (None, new_ol)
            href = get_resource_url(env, context.resource, context.href)
            if href.endswith(context.req.path_info):
                href = ''
            href += '#' + anchor
            li, ol = stack[depth]
            li = tag.li(tag.a(Markup(heading), href=href),
                        class_=active and 'active' or None)
            ol.append(li)
            stack[depth] = (li, ol)
            previous_depth = depth
    return stack[min_depth][0]
Exemple #4
0
    def expand_macro(self, formatter, name, content):
        citelist = getattr(formatter, CITELIST, [])
        bibdb = getattr(formatter, BIBDB, {})

        page = WikiPage(self.env, 'BibTex')
        if page.exists:
            if '{{{' in page.text and '}}}' in page.text:
                tmp = re.compile('{{{|}}}', 2).split(page.text)
                bibdb.update(extract_entries(tmp[1]))
                setattr(formatter, BIBDB, bibdb)

        str = ''
        for k in citelist:
            if bibdb.has_key(k) == False:
                str += 'No entry ' + k + ' found.\n'
        if str != '':
            raise TracError('[[' + str + ']]')

        l = []
        for k in citelist:
            content = []
            for bibkey in BIBTEX_KEYS:
                if bibdb[k].has_key(bibkey):
                    content.append(tag.span(Markup(bibdb[k][bibkey] + ', ')))
            if bibdb[k].has_key('url') == False:
                l.append(
                    tag.li(tag.a(name=k),
                           tag.a(href='#cite_%s' % k)('^'), content))
            else:
                url = bibdb[k]['url']
                l.append(
                    tag.li(tag.a(name=k),
                           tag.a(href='#cite_%s' % k)('^'), content, tag.br(),
                           tag.a(href=url)(url)))

        ol = tag.ol(*l)
        tags = []
        tags.append(tag.h1(id='References')('References'))
        tags.append(ol)

        return tag.div(id='References')(*tags)
Exemple #5
0
  def expand_macro(self,formatter,name,content):
    citelist = getattr(formatter, CITELIST,[])
    bibdb = getattr(formatter, BIBDB,{})

    page = WikiPage(self.env,'BibTex')
    if page.exists:
      if '{{{' in page.text and '}}}' in page.text:
        tmp = re.compile('{{{|}}}',2).split(page.text)
        bibdb.update(extract_entries(tmp[1]))
        setattr(formatter,BIBDB,bibdb)

    str = ''
    for k in citelist:
      if bibdb.has_key(k) == False:
        str +='No entry ' + k + ' found.\n'
    if str != '':
      raise TracError('[[' + str + ']]')

    l = []
    for k in citelist:
      content = []
      for bibkey in BIBTEX_KEYS:
        if bibdb[k].has_key(bibkey):
          content.append(tag.span(Markup(bibdb[k][bibkey] + ', ')))
      if bibdb[k].has_key('url') == False:
        l.append(tag.li(tag.a(name=k), tag.a(href='#cite_%s' % k)('^') ,content))
      else:
        url = bibdb[k]['url']
        l.append(tag.li(tag.a(name=k), tag.a(href='#cite_%s' % k)('^') ,content, tag.br(),tag.a(href=url)(url)))

    ol = tag.ol(*l)
    tags = []
    tags.append(tag.h1(id='References')('References'))
    tags.append(ol)

    return tag.div(id='References')(*tags)
Exemple #6
0
	def __call__(self,obj,depth=0,dontRender=False):
		from genshi.builder import tag
		if depth>self.maxDepth: raise RuntimeError("Maximum nesting depth %d exceeded"%self.maxDepth)
		kw=self.padding.copy()
		if depth>0: kw.update(width='100%')
		# was [1:] to omit leading woo./wooExtra., but that is not desirable
		head=tag.b('.'.join(obj.__class__.__module__.split('.')[0:])+'.'+obj.__class__.__name__)
		head=tag.a(head,href=woo.document.makeObjectUrl(obj),title=_ensureUnicode(obj.__class__.__doc__))
		ret=tag.table(tag.th(head,colspan=3,align='left'),frame='box',rules='all',**kw)
		# get all attribute traits first
		traits=obj._getAllTraits()
		for trait in traits:
			if trait.hidden or (self.hideNoGui and trait.noGui) or trait.noDump or (trait.hideIf and eval(trait.hideIf,globals(),{'self':obj})): continue
			# start new group (additional line)
			if trait.startGroup:
				ret.append(tag.tr(tag.td(tag.i(u'▸ %s'%_ensureUnicode(trait.startGroup)),colspan=3)))
			attr=getattr(obj,trait.name)
			if self.showDoc: tr=tag.tr(tag.td(_ensureUnicode(trait.doc)))
			else:
				try:
					tr=tag.tr(tag.td(tag.a(trait.name,href=woo.document.makeObjectUrl(obj,trait.name),title=_ensureUnicode(trait.doc))))
				except UnicodeEncodeError:
					print 'ERROR: UnicodeEncodeError while formatting the attribute ',obj.__class__.__name__+'.'+trait.name
					print 'ERROR: the docstring is',trait.doc
					raise
			# tr=tag.tr(tag.td(trait.name if not self.showDoc else trait.doc.decode('utf-8')))
			# nested object
			if isinstance(attr,woo.core.Object):
				tr.append([tag.td(self(attr,depth+1),align='justify'),tag.td()])
			# sequence of objects (no units here)
			elif hasattr(attr,'__len__') and len(attr)>0 and isinstance(attr[0],woo.core.Object):
				tr.append(tag.td(tag.ol([tag.li(self(o,depth+1)) for o in attr])))
			else:
				# !! make deepcopy so that the original object is not modified !!
				import copy
				attr=copy.deepcopy(attr)
				if not trait.multiUnit: # the easier case
					if not trait.prefUnit: unit=u'−'
					else:
						unit=_ensureUnicode(trait.prefUnit[0][0])
						# create new list, where entries are multiplied by the multiplier
						if type(attr)==list: attr=[a*trait.prefUnit[0][1] for a in attr]
						else: attr=attr*trait.prefUnit[0][1]
				else: # multiple units
					unit=[]
					wasList=isinstance(attr,list)
					if not wasList: attr=[attr] # handle uniformly
					for i in range(len(attr)):
						attr[i]=[attr[i][j]*trait.prefUnit[j][1] for j in range(len(attr[i]))]
					for pu in trait.prefUnit:
						unit.append(_ensureUnicode(pu[0]))
					if not wasList: attr=attr[0]
					unit=', '.join(unit)
				# sequence type, or something similar				
				if hasattr(attr,'__len__') and not isinstance(attr,str):
					if len(attr)>0:
						tr.append(tag.td(self.htmlSeq(attr,insideTable=False),align='right'))
					else:
						tr.append(tag.td(tag.i('[empty]'),align='right'))
				else:
					tr.append(tag.td(float2str(attr) if isinstance(attr,float) else str(attr),align='right'))
				if unit:
					tr.append(tag.td(unit,align='right'))
			ret.append(tr)
		if depth>0 or dontRender: return ret
		return ret.generate().render('xhtml',encoding='ascii')+b'\n'
Exemple #7
0
    def expand_macro(self, formatter, name, content):
        # Make sure data capsule is in place
        if not hasattr(formatter, '_footnotes'):
            formatter._footnotes = []

        # Chrome
        add_stylesheet(formatter.req, 'footnote/footnote.css')
        add_script(formatter.req, 'footnote/footnote.js')

        if content:
            # Add a new footnote
            try:
                # Reference to an existing footnote
                output_id = int(content)

                try:
                    content = formatter._footnotes[output_id-1][0]
                except IndexError:
                    content = 'Unknown footnote'
            except ValueError:
                output_id = None

                # Try to collate with an existing footnote
                for i in xrange(len(formatter._footnotes)):
                    if formatter._footnotes[i][0] == content:
                        output_id = i + 1
                        break

                # Format markup
                markup = format_to_oneliner(self.env, formatter.context, content)

                # Adding a new footnote
                if not output_id:
                    formatter._footnotes.append((content, markup))
                    output_id = len(formatter._footnotes)

            return tag.sup(
                tag.a(
                    output_id,
                    title=shorten_line(content, 50),
                    id='FootNoteRef%s'%output_id,
                    href='#FootNote%s'%output_id,
                ),
                class_='footnote',
            )
        else:
            # Dump all accumulated notes
            footnotes = formatter._footnotes[:]
            formatter._footnotes = [(content, None) for content, markup in footnotes]
            if formatter._footnotes:
                return tag.div(
                    tag.hr(),
                    tag.ol(
                        [tag.li(
                            tag.a(
                                '%s.'%(i+1),
                                href='#FootNoteRef%s'%(i+1),
                                class_='sigil',
                            ),
                            ' ',
                            markup,
                            id='FootNote%s'%(i+1),
                        ) for i, (content, markup) in enumerate(footnotes) if markup],
                    ),
                    class_='footnotes',
                )
            else:
                return []
Exemple #8
0
 def __call__(self,obj,depth=0,dontRender=False):
     from genshi.builder import tag
     if depth>self.maxDepth: raise RuntimeError("Maximum nesting depth %d exceeded"%self.maxDepth)
     kw=self.padding.copy()
     if depth>0: kw.update(width='100%')
     # was [1:] to omit leading woo./wooExtra., but that is not desirable
     objInExtra=obj.__class__.__module__.startswith('wooExtra.')
     if self.hideWooExtra and objInExtra: head=tag.span(tag.b(obj.__class__.__name__),title=_ensureUnicode(obj.__class__.__doc__))
     else: 
         head=tag.b('.'.join(obj.__class__.__module__.split('.')[0:])+'.'+obj.__class__.__name__)
         head=tag.a(head,href=woo.document.makeObjectUrl(obj),title=_ensureUnicode(obj.__class__.__doc__))
     ret=tag.table(tag.th(head,colspan=3,align='left'),frame='box',rules='all',**kw)
     # get all attribute traits first
     traits=obj._getAllTraits()
     for trait in traits:
         if trait.hidden or (self.hideNoGui and trait.noGui) or trait.noDump or (trait.hideIf and eval(trait.hideIf,globals(),{'self':obj})): continue
         # start new group (additional line)
         if trait.startGroup:
             ret.append(tag.tr(tag.td(tag.i(u'▸ %s'%_ensureUnicode(trait.startGroup)),colspan=3)))
         attr=getattr(obj,trait.name)
         if self.showDoc: tr=tag.tr(tag.td(_ensureUnicode(trait.doc)))
         else:
             try:
                 if self.hideWooExtra and objInExtra: label=tag.span(tag.b(trait.name),title=_ensureUnicode(trait.doc))
                 else: label=tag.a(trait.name,href=woo.document.makeObjectUrl(obj,trait.name),title=_ensureUnicode(trait.doc))
                 tr=tag.tr(tag.td(label))
             except UnicodeEncodeError:
                 print('ERROR: UnicodeEncodeError while formatting the attribute ',obj.__class__.__name__+'.'+trait.name)
                 print('ERROR: the docstring is',trait.doc)
                 raise
         # tr=tag.tr(tag.td(trait.name if not self.showDoc else trait.doc.decode('utf-8')))
         # nested object
         if isinstance(attr,woo.core.Object):
             tr.append([tag.td(self(attr,depth+1),align='justify'),tag.td()])
         # sequence of objects (no units here)
         elif hasattr(attr,'__len__') and len(attr)>0 and isinstance(attr[0],woo.core.Object):
             tr.append(tag.td(tag.ol([tag.li(self(o,depth+1)) for o in attr])))
         else:
             # !! make deepcopy so that the original object is not modified !!
             import copy
             attr=copy.deepcopy(attr)
             if not trait.multiUnit: # the easier case
                 if not trait.prefUnit: unit=u'−'
                 else:
                     unit=_ensureUnicode(trait.prefUnit[0][0])
                     # create new list, where entries are multiplied by the multiplier
                     if type(attr)==list: attr=[a*trait.prefUnit[0][1] for a in attr]
                     else: attr=attr*trait.prefUnit[0][1]
             else: # multiple units
                 unit=[]
                 wasList=isinstance(attr,list)
                 if not wasList: attr=[attr] # handle uniformly
                 for i in range(len(attr)):
                     attr[i]=[attr[i][j]*trait.prefUnit[j][1] for j in range(len(attr[i]))]
                 for pu in trait.prefUnit:
                     unit.append(_ensureUnicode(pu[0]))
                 if not wasList: attr=attr[0]
                 unit=', '.join(unit)
             # sequence type, or something similar                
             if hasattr(attr,'__len__') and not isinstance(attr,(str,unicode,bytes)):
                 if len(attr)>0:
                     tr.append(tag.td(self.htmlSeq(attr,insideTable=False),align='right'))
                 else:
                     tr.append(tag.td(tag.i('[empty]'),align='right'))
             else:
                 tr.append(tag.td(float2str(attr) if isinstance(attr,float) else str(attr),align='right'))
             if unit:
                 tr.append(tag.td(unit,align='right'))
         ret.append(tr)
     if depth>0 or dontRender: return ret
     r1=ret.generate().render('xhtml',encoding='ascii')
     if isinstance(r1,bytes): r1=r1.decode('ascii')
     return r1+u'\n'
Exemple #9
0
    def expand_macro(self, formatter, name, content):
        # Make sure data capsule is in place
        if not hasattr(formatter, "_footnotes"):
            formatter._footnotes = []

        # Chrome
        add_stylesheet(formatter.req, "footnote/footnote.css")
        add_script(formatter.req, "footnote/footnote.js")

        if content:
            # Add a new footnote
            try:
                # Reference to an existing footnote
                output_id = int(content)

                try:
                    content = formatter._footnotes[output_id - 1][0]
                except IndexError:
                    content = "Unknown footnote"
            except ValueError:
                output_id = None

                # Try to collate with an existing footnote
                for i in xrange(len(formatter._footnotes)):
                    if formatter._footnotes[i][0] == content:
                        output_id = i + 1
                        break

                # Format markup
                markup = format_to_oneliner(self.env, formatter.context, content)

                # Adding a new footnote
                if not output_id:
                    formatter._footnotes.append((content, markup))
                    output_id = len(formatter._footnotes)

            return tag.sup(
                tag.a(
                    output_id,
                    title=shorten_line(content, 50),
                    id="FootNoteRef%s" % output_id,
                    href="#FootNote%s" % output_id,
                ),
                class_="footnote",
            )
        else:
            # Dump all accumulated notes
            footnotes = formatter._footnotes[:]
            formatter._footnotes = [(content, None) for content, markup in footnotes]
            if formatter._footnotes:
                return tag.div(
                    tag.hr(),
                    tag.ol(
                        [
                            tag.li(
                                tag.a("%s." % (i + 1), href="#FootNoteRef%s" % (i + 1), class_="sigil"),
                                " ",
                                markup,
                                id="FootNote%s" % (i + 1),
                            )
                            for i, (content, markup) in enumerate(footnotes)
                            if markup
                        ]
                    ),
                    class_="footnotes",
                )
            else:
                return []
Exemple #10
0
 def expand_macro(self, formatter, name, content):
     """
     """
     args, kwargs = parse_args(content, strict=False)
     kwargs = string_keys(kwargs)
     
     cite_list = getattr(formatter, CITE_LIST, [])
     cite_dict = getattr(formatter, CITE_DICT, {})
     
     if len(args) == 1:
         label = args[0]
         description = ''
     
     if len(args) == 2:
         label = args[0]
         description = args[1]
     
     # Allow for extra parameters, people can use it to store BibTeX data.
     if len(args) == 0:
         raise TracError('At the very least a `label` is required.')
     
     # `makeindex` will not make sense to non-LaTeX users.
     if label == 'references':
         h = kwargs.get('h', '1')
         backref = kwargs.get('backref')
         
         tags = []
         if h == '1':
             root = tag.h1
         elif h == '2':
             root = tag.h2
         elif h == '3':
             root = tag.h3
         elif h == '4':
             root = tag.h4
         else:
             root = tag.h5
         
         tags.append(root(id='References')('References'))
         
         li = []
         for index, label in enumerate(cite_list):
             description, params = cite_dict[label]
             
             if description:
                 line = [description]
             else:
                 line = []
             
             for key in REFERENCE_SEQUENCE:
                 value = params.get(key)
                 if value:
                     reference_formatter = REFERENCE_FORMAT[key]
                     if callable(reference_formatter):
                         value = reference_formatter(value, params)
                     elif reference_formatter.find('%s') >= 0:
                         value = reference_formatter % value
                     else:
                         continue
                     
                     if value:
                         line.append(value)
             
             entry = ', '.join(line)
             
             url = params.get('url')
             
             if entry and url:
                 entry += ','
             
             if entry:
                 if url:
                     if backref:
                         li.append(tag.li(tag.a(name=label), tag.a(href='#cite_%s' % label)('^'), ' ', entry, tag.br(), tag.a(href=url)(url)))
                     else:
                         li.append(tag.li(tag.a(name=label), entry, tag.br(), tag.a(href=url)(url)))
                 else:
                     if backref:
                         li.append(tag.li(tag.a(name=label), tag.a(href='#cite_%s' % label)('^'), ' ', entry))
                     else:
                         li.append(tag.li(tag.a(name=label), entry))
             else:
                 if url:
                     if backref:
                         li.append(tag.li(tag.a(name=label), tag.a(href='#cite_%s' % label)('^'), ' ', tag.a(href=url)(url)))
                     else:
                         li.append(tag.li(tag.a(name=label), tag.a(href=url)(url)))
         
         ol = tag.ol(*li)
         tags.append(ol)
         
         # This is ugly but it is easy.
         return tag.div(id='References')(*tags)
     
     elif label == 'bibtex':
         indent = kwargs.get('indent', 2)
         try:
             indent = int(indent)
             indent = (indent, 0)[indent < 0]
             indent = (indent, 8)[indent > 8]
         except ValueError:
             intent = 2
         
         references = []
         for index, label in enumerate(cite_list):
             description, params = cite_dict[label]
             reftype = params.get('reftype', 'Book')
             
             reference = []
             reference.append('@%s{%s' % (reftype, label))
             for key in BIBTEX_SEQUENCE:
                 value = params.get(key)
                 if value:
                     bibtex_formatter = BIBTEX_FORMAT[key]
                     if callable(bibtex_formatter):
                         value = bibtex_formatter(value, params)
                     elif bibtex_formatter.find('%s') >= 0:
                         value = bibtex_formatter % value
                     else:
                         continue
                     
                     if value:
                         reference.append(',\n%s%s = "%s"' % (' ' * indent, key, value))
             
             if len(reference) == 1:
                 reference.append(',')
             
             reference.append('\n};')
             references.append(''.join(reference))
         
         if 'class' in kwargs:
             kwargs['class_'] = kwargs.pop('class')
         
         return tag.pre('\n\n'.join(references), **kwargs)
     
     else:
         if label not in cite_list:
             cite_list.append(label)
             cite_dict[label] = (description, kwargs)
             
             setattr(formatter, CITE_LIST, cite_list)
             setattr(formatter, CITE_DICT, cite_dict)
             backref = True
         else:
             backref = False
         
         index = cite_list.index(label) + 1
         
         if backref:
             return ''.join(['[', str(tag.a(name='cite_%s' % label)), str(tag.a(href='#%s' % label)('%d' % index)), ']'])
         else:
             return ''.join(['[', str(tag.a(href='#%s' % label)('%d' % index)), ']'])
Exemple #11
0
    def expand_macro(self, formatter, name, content):
        args, kwargs = parse_args(content, strict=False)

        if len(args) == 1:
            hat = args[0].lower()
            title = TITLES.get(hat, '')

        elif len(args) == 2:
            hat = args[0].lower()
            title = args[1]

        # An simple Exception would probabl;y be better, see http://../ for examples.
        if len(args) == 0 or hat not in ('black', 'blue', 'green', 'red',
                                         'white', 'yellow', 'intro', 'cite'):
            raise TracError(
                'Invalid parameters, see http://trac-hacks.org/wiki/SixhatsMacro#Examples for example uses.'
            )
            #tags = [tag.strong()('Error: Invalid parameters, see the following examples:')]
            #tags.extend([tag.pre()(i) for i in HELP.splitlines()])
            #return tag.div(class_='system-message')(*tags)

        if hat == 'cite':
            if not title:
                title = "The best way to learn the Six Hats method is to read Edward de Bono's "
            url = get_absolute_url(
                formatter.href.base,
                'htdocs://sixhats/pdf/six_thinking_hats.pdf')
            return tag.p()(title, tag.a(href=url)('Six Thinking Hats'), '.')

        # Not too sure if a plugin should be self-documenting.
        if hat == 'intro':
            hide = kwargs.get('hide')

            tags = []
            tags.append(
                tag.h1(id='SixHatsIntroduction')('Six Hats Introduction'))
            tags.append(
                tag.blockquote(
                    tag.
                    p("There is nothing more sad and wasteful than a roomful of intelligent and highly paid people waiting for a chance to attack something the speaker has said. With the Six Hats method the fullest use is made of everyone's intelligence, experience and information. The Six Hats also removes all 'ego' from the discussion process."
                      )))
            tags.append(
                tag.p(
                    'The Six Thinking Hats represent directions of thought. They are used to request thinking in a paticular direction, ',
                    tag.strong('not'),
                    ' as a description or label to classify your thinking afterwards. They are ',
                    tag.strong('not'),
                    ' used to characterize people. A person is not a black hat, but he or she might prefer to think with the black hat on. It is desirable for everyone to become skilled in the use of all the hats.'
                ))
            tags.append(self.expand_macro(formatter, name, 'cite'))
            tags.append(tag.h1(id='Summary')('Summary'))
            tags.append(self.expand_macro(formatter, name, 'white,size=m'))

            li = [
                tag.li('The white hat is neutral and objective.'),
                tag.li('It focusses on facts and figures.'),
            ]

            sub_li = [
                tag.li('What information do we have?'),
                tag.li('What information do we need?'),
                tag.li('What information is missing?'),
                tag.li('What questions do we need to ask?'),
                tag.li('How are we going to get the information we need?')
            ]

            li.append(
                tag.li('Questions to ask with the white hat on:',
                       tag.ul(*sub_li)))
            li.extend([
                tag.
                li('The information can range from hard verifiable facts and figures to soft information such as 3rd party opinions and feelings. Your own opinions and feelings are placed under the red hat.'
                   ),
                tag.li('Whose fact is it?'),
                tag.li('Is the information a fact, a likelyhood or a believe?')
            ])

            sub_li = [
                tag.li('Always true'),
                tag.li('Usually true'),
                tag.li('Generally true'),
                tag.li('By and large'),
                tag.li('More often than not'),
                tag.li('About half the time'),
                tag.li('Often'),
                tag.li('Sometimes true'),
                tag.li('Occastionally true'),
                tag.li('Been known to happen'),
                tag.li('Never true'),
                tag.li('Cannot be true (contradictory)')
            ]

            li.append(
                tag.
                li('How true is the fact? Frame the information appropriatly:',
                   tag.ul(*sub_li)))
            li.append(
                tag.
                li('Split the facts into two groups: checked facts and believed facts.'
                   ))
            tags.append(tag.ul(*li))

            tags.append(self.expand_macro(formatter, name, 'red,size=m'))

            li = [
                tag.li(
                    'The red hat is subjective and generally non-rational.'),
                tag.li('It exposes and legitimizes emotions and feelings.'),
                tag.
                li('It allows people to express their opinions, hunches, intuitions and impressions. (a function of their experience)'
                   ),
                tag.
                li("Resist the temptation to justify your emotions. You don't need to give a reason or a logical basis."
                   ),
                tag.
                li('If emotions and feelings are not permitted as inputs in the thinking process, they will lurk in the background and affect all the thinking in a hidden way.'
                   ),
                tag.
                li('The red hat makes feelings visible so that they can become part of the thinking map and also part of the value system that chooses the route on the map.'
                   )
            ]

            sub_li = [
                tag.
                li('Ordinary emotions such as fear and dislike to more subtle ones such as suspicion.'
                   ),
                tag.
                li('Complex judgements that go into such type of feelings as a hunch, intuition, sense, taste, aesthetic feeling and other not visibly justified types of feeling.'
                   )
            ]

            li.append(
                tag.li('The red hat covers two broad types of feelings:',
                       tag.ol(*sub_li)))
            tags.append(tag.ul(*li))

            tags.append(self.expand_macro(formatter, name, 'black,size=m'))

            li = [
                tag.
                li('The black hat is critical and logical (negative judgements).'
                   ),
                tag.
                li("It's perhaps the most important hat, the hat of survival, of caution and of being careful."
                   ),
                tag.
                li('It points out how something does not fit our experience, our resources, our policy, our stragegy, our ethics, our values, etc.'
                   ),
                tag.
                li('It protects us from wasting energy and money, it seeks to avoid dangers, problems, obstacles and difficulties.'
                   ),
                tag.
                li('There must be a logical basis for the criticism and reasons must be capable of standing on their own.'
                   ),
                tag.
                li('It focuses on why something may not work or may not be the right thing to do.'
                   ),
            ]

            sub_li = [
                tag.li('Be as causious and as fiercely critical as possible.'),
                tag.li(
                    'Point out errors or deficiencies in the thinking process.'
                ),
                tag.li('Question the strength of the evidence.'),
                tag.li('What are the risks?'),
            ]

            li.append(
                tag.li(
                    'In order to get the full value from any suggestion or idea, it is important that the black hat be done thoroughly:',
                    tag.ul(*sub_li)))
            li.extend([
                tag.
                li('Black hat thinking is not argument and must not be allowed to degenerate into argument.'
                   ),
                tag.li(
                    tag.strong('Caution:'),
                    ' There are people who overuse the black hat and who spend all their time trying to find fault. The fault is not in the black hat but in the abuse, overuse or misuse of the black hat.'
                )
            ])

            tags.append(tag.ul(*li))

            tags.append(self.expand_macro(formatter, name, 'yellow,size=m'))

            li = [
                tag.
                li('The yellow hat is optimistic and logical (positive judgements).'
                   )
            ]

            sub_li = [
                tag.li('The generation of proposals.'),
                tag.li('The positive assessment of proposals.'),
                tag.li("Developing or 'building up' of proposals.")
            ]

            li.append(
                tag.li('The yellow hat is concerned with:', tag.ol(*sub_li)))
            li.extend([
                tag.
                li('Under the yellow hat a thinker deliberatly sets out to find whatever benefit there may be in a suggestion.'
                   ),
                tag.
                li('It is a waste of time setting out to be creative if you are not going to recognize a good idea.'
                   ),
                tag.li('Value and benefit are by no means always obvious.'),
                tag.
                li('Since the yellow hat is logical you should give a reason for the value you put forward.'
                   ),
                tag.
                li('The emphasis of yellow hat thinking is on exploration and positive speculation, oppertunity seeking.'
                   ),
                tag.
                li("Yellow hat thinking is concerned with the positive attitude of getting the job done, let's make it happen."
                   )
            ])

            tags.append(tag.ul(*li))

            tags.append(self.expand_macro(formatter, name, 'green,size=m'))

            li = [
                tag.li('The green hat is creative, sometimes illogical.'),
                tag.
                li('The green hat is concerned with new ideas and new ways of looking at things, new perceptions.'
                   ),
                tag.
                li("Under the green hat we lay out options, alternatives and 'possibilities'."
                   ),
                tag.
                li('It corrects the faults found under the black hat and find noval ways the exploit the opportunities identified under the yellow hat.'
                   ),
                tag.
                li('You use the green hat to deliberately go after new ideas instead of waiting for them to come to you.'
                   ),
                tag.
                li('Sometimes you may be required to put forward provocations, illogical ideas, in order to provoke new concepts.'
                   ),
                tag.
                li('Under the green hat we use ideas as stepping stones, for their movement value, moving us to new ideas.'
                   ),
                tag.li('Use random words and ', tag.em('Po'), '.')
            ]

            tags.append(tag.ul(*li))

            tags.append(self.expand_macro(formatter, name, 'blue,size=m'))

            li = [
                tag.
                li('The blue hat is for meta-thinking, thinking about thinking.'
                   ),
                tag.
                li('Wearing the blue hat we are no longer thinking about the subject; instead, we are thinking about the thinking needed to explore the subject.'
                   ),
                tag.
                li('The blue hat thinker is like the conductor of an orchestra.'
                   ),
                tag.
                li("Generally the blue hat is worn by the facilitator, chairperson or leader of the session, it's a permanent role."
                   ),
                tag.
                li('The blue hat is for the organization and management of thinking, it also controls the process of thinking.'
                   ),
                tag.
                li('The initial blue hat defines the problem, list constraints and sets the agenda, the sequence of the other hats to be used.'
                   ),
                tag.
                li('Blue hat thinking stops arguments, enforces the discipline and keep people focussed on map making.'
                   ),
                tag.
                li('The final blue hat is responsible for summaries, overviews and conclusions.'
                   )
            ]

            tags.append(tag.ul(*li))

            fedoras = tag.a('fedoras',
                            href=get_absolute_url(
                                formatter.href.base,
                                'htdocs://sixhats/img/source/fedoras.svg'))
            hardhats = tag.a('hardhats',
                             href=get_absolute_url(
                                 formatter.href.base,
                                 'htdocs://sixhats/img/source/hardhats.svg'))
            tophats = tag.a('tophats',
                            href=get_absolute_url(
                                formatter.href.base,
                                'htdocs://sixhats/img/source/tophats.svg'))

            tags.append(
                tag.p(
                    'PS. If you wish to use any of these images in your own documents rather use the high quality vectors: ',
                    fedoras, ', ', hardhats, ' and ', tophats, '.'))

            if hide:
                add_script(formatter.req, 'sixhats/js/hide.js')

                if hide.lower() == 'hide':
                    return ''.join([
                        str(i) for i in
                        ('- ',
                         tag.a(id='hide', href='#', style='font-size: 8pt;')(
                             'show six hats introduction'), ' -',
                         tag.div(
                             id='introduction', style='display: none;', *tags))
                    ])
                else:
                    return ''.join([
                        str(i) for i in (
                            '- ',
                            tag.a(id='hide', href='#', style='font-size: 8pt;')
                            ('hide six hats introduction'), ' -',
                            tag.div(id='introduction', *tags))
                    ])
            else:
                return tag.div(id='introduction', *tags)

        id = kwargs.get('id', squish_string(title))
        size = kwargs.get('size', 'large')
        type = kwargs.get('type', 'hardhat').lower()
        h = kwargs.get('h')

        if type in ('fedora', 'hardhat', 'tophat'):
            if size.endswith('%'):
                percentage = float(size.strip('%')) / 100.0
                width, height = SIZES[type]['l']
            else:
                percentage = 1
                width, height = SIZES[type][size[0]]

            width = int(width * percentage)
            height = int(height * percentage)

        if h:
            if h == '1':
                root = tag.h1
            elif h == '2':
                root = tag.h2
            elif h == '3':
                root = tag.h3
            elif h == '4':
                root = tag.h4
            else:
                root = tag.h5
        else:
            s0 = size[0]
            if s0 == 'l':
                root = tag.h1
            elif s0 == 'm':
                root = tag.h2
            elif s0 == 's':
                root = tag.h3
            else:
                root = tag.h1

        url = get_absolute_url(
            formatter.href.base,
            'htdocs://sixhats/img/%(type)s/%(hat)s.jpg' % {
                'type': type,
                'hat': hat
            })

        if id:
            return root(id=id)(tag.img(src=url, width=width, height=height),
                               title)
        else:
            return root()(tag.img(src=url, width=width, height=height), title)
Exemple #12
0
    def expand_macro(self, formatter, name, args):
        context = formatter.context
        resource = formatter.context.resource

        # Bail out if we are in a no-float zone
        if hasattr(formatter, 'properties') and \
               'macro_no_float' in formatter.properties:
            return ''

        current_page = resource.id

        # Split the args
        args, kw = parse_args(args)
        # Options
        inline = False
        pagenames = []

        default_heading = 'Table of Contents'
        params = {'min_depth': 1, 'max_depth': 6}
        # Global options
        for arg in args:
            arg = arg.strip()
            if arg == 'inline':
                inline = True
            elif arg == 'noheading':
                default_heading = ''
            elif arg == 'notitle':
                params['min_depth'] = 2  # Skip page title
            elif (arg == 'titleindex') or (arg == 'sectionindex'):
                # sectionindex is a page-context sensitive titleindex
                if arg == 'sectionindex':
                    params['section_index'] = True
                params['title_index'] = True
                default_heading = default_heading and 'Page Index'
            elif arg == 'nofloat':
                return ''
            elif arg != '':
                pagenames.append(arg)
        heading = kw.pop('heading', '') or default_heading

        if 'depth' in kw:
            params['max_depth'] = int(kw['depth'])

        # Has the user supplied a list of pages?
        if not pagenames:
            # Be sure to test section_index first as title_index is also true in this case
            if 'section_index' in params:
                # Use 'parent' of current page (level delimiter is /), if any
                toks = re.match('^(?P<parent>.*)/[^/]*$', current_page)
                if toks:
                    pagenames.append(toks.group('parent') + '/')
                else:
                    pagenames.append('*')
            elif 'title_index' in params:
                pagenames.append('*')  # A marker for 'all'
            else:
                pagenames.append(current_page)
                params['root'] = ''
                params['min_depth'] = 2  # Skip page title
        # Check for wildcards and expand lists
        temp_pagenames = []
        for pagename in pagenames:
            if 'section_index' in params:
                # / is considered an equivalent to * in sectionindex
                if pagename == '/':
                    pagename = '*'
                if not pagename.endswith('*'):
                    pagename += '*'
            if pagename.endswith('*'):
                temp_pagenames.extend(
                    sorted(WikiSystem(self.env).get_pages(pagename[:-1])))
            else:
                temp_pagenames.append(pagename)
        pagenames = temp_pagenames

        base = tag.div(class_=inline and 'wiki-toc-inline' or 'wiki-toc')
        ol = tag.ol()
        base.append([heading and tag.h4(heading), ol])

        active = len(pagenames) > 1
        for pagename in pagenames:
            page_resource = resource(id=pagename)
            if not 'WIKI_VIEW' in context.perm(page_resource):
                # Not access to the page, so should not be included
                continue
            if 'title_index' in params:
                self._render_title_index(formatter, ol, page_resource, active
                                         and pagename == current_page,
                                         params['min_depth'] < 2)
            else:
                self._render_page_outline(formatter, ol, page_resource, active,
                                          params)
        return base
Exemple #13
0
 def expand_macro(self, formatter, name, content):
     args, kwargs = parse_args(content, strict=False)
     
     if len(args) == 1:
         hat = args[0].lower()
         title = TITLES.get(hat, '')
     
     elif len(args) == 2:
         hat = args[0].lower()
         title = args[1]
     
     # An simple Exception would probabl;y be better, see http://../ for examples.
     if len(args) == 0 or hat not in ('black', 'blue', 'green', 'red', 'white', 'yellow', 'intro', 'cite'):
         raise TracError('Invalid parameters, see http://trac-hacks.org/wiki/SixhatsMacro#Examples for example uses.')
         #tags = [tag.strong()('Error: Invalid parameters, see the following examples:')]
         #tags.extend([tag.pre()(i) for i in HELP.splitlines()])
         #return tag.div(class_='system-message')(*tags)
     
     if hat == 'cite':
         if not title:
             title = "The best way to learn the Six Hats method is to read Edward de Bono's "
         url = get_absolute_url(formatter.href.base, 'htdocs://sixhats/pdf/six_thinking_hats.pdf')
         return tag.p()(title, tag.a(href=url)('Six Thinking Hats'), '.')
     
     # Not too sure if a plugin should be self-documenting.
     if hat == 'intro':
         hide = kwargs.get('hide')
         
         tags = []
         tags.append(tag.h1(id='SixHatsIntroduction')('Six Hats Introduction'))
         tags.append(tag.blockquote(tag.p("There is nothing more sad and wasteful than a roomful of intelligent and highly paid people waiting for a chance to attack something the speaker has said. With the Six Hats method the fullest use is made of everyone's intelligence, experience and information. The Six Hats also removes all 'ego' from the discussion process.")))
         tags.append(tag.p('The Six Thinking Hats represent directions of thought. They are used to request thinking in a paticular direction, ', tag.strong('not'), ' as a description or label to classify your thinking afterwards. They are ', tag.strong('not'), ' used to characterize people. A person is not a black hat, but he or she might prefer to think with the black hat on. It is desirable for everyone to become skilled in the use of all the hats.'))
         tags.append(self.expand_macro(formatter, name, 'cite'))
         tags.append(tag.h1(id='Summary')('Summary'))
         tags.append(self.expand_macro(formatter, name, 'white,size=m'))
         
         li = [
             tag.li('The white hat is neutral and objective.'),
             tag.li('It focusses on facts and figures.'),
         ]
         
         sub_li = [ 
             tag.li('What information do we have?'),
             tag.li('What information do we need?'),
             tag.li('What information is missing?'),
             tag.li('What questions do we need to ask?'),
             tag.li('How are we going to get the information we need?')
         ]
         
         li.append(tag.li('Questions to ask with the white hat on:', tag.ul(*sub_li)))
         li.extend([
             tag.li('The information can range from hard verifiable facts and figures to soft information such as 3rd party opinions and feelings. Your own opinions and feelings are placed under the red hat.'),
             tag.li('Whose fact is it?'),
             tag.li('Is the information a fact, a likelyhood or a believe?')
         ])
         
         sub_li = [
             tag.li('Always true'),
             tag.li('Usually true'),
             tag.li('Generally true'),
             tag.li('By and large'),
             tag.li('More often than not'),
             tag.li('About half the time'),
             tag.li('Often'),
             tag.li('Sometimes true'),
             tag.li('Occastionally true'),
             tag.li('Been known to happen'),
             tag.li('Never true'),
             tag.li('Cannot be true (contradictory)')
         ]
         
         li.append(tag.li('How true is the fact? Frame the information appropriatly:', tag.ul(*sub_li)))
         li.append(tag.li('Split the facts into two groups: checked facts and believed facts.'))
         tags.append(tag.ul(*li))
         
         tags.append(self.expand_macro(formatter, name, 'red,size=m'))
         
         li = [
             tag.li('The red hat is subjective and generally non-rational.'),
             tag.li('It exposes and legitimizes emotions and feelings.'),
             tag.li('It allows people to express their opinions, hunches, intuitions and impressions. (a function of their experience)'),
             tag.li("Resist the temptation to justify your emotions. You don't need to give a reason or a logical basis."),
             tag.li('If emotions and feelings are not permitted as inputs in the thinking process, they will lurk in the background and affect all the thinking in a hidden way.'),
             tag.li('The red hat makes feelings visible so that they can become part of the thinking map and also part of the value system that chooses the route on the map.')
         ]
         
         sub_li = [
             tag.li('Ordinary emotions such as fear and dislike to more subtle ones such as suspicion.'),
             tag.li('Complex judgements that go into such type of feelings as a hunch, intuition, sense, taste, aesthetic feeling and other not visibly justified types of feeling.')
         ]
         
         li.append(tag.li('The red hat covers two broad types of feelings:', tag.ol(*sub_li)))
         tags.append(tag.ul(*li))
         
         tags.append(self.expand_macro(formatter, name, 'black,size=m'))
         
         li = [
             tag.li('The black hat is critical and logical (negative judgements).'),
             tag.li("It's perhaps the most important hat, the hat of survival, of caution and of being careful."),
             tag.li('It points out how something does not fit our experience, our resources, our policy, our stragegy, our ethics, our values, etc.'),
             tag.li('It protects us from wasting energy and money, it seeks to avoid dangers, problems, obstacles and difficulties.'),
             tag.li('There must be a logical basis for the criticism and reasons must be capable of standing on their own.'),
             tag.li('It focuses on why something may not work or may not be the right thing to do.'),
         ]
         
         sub_li = [ 
             tag.li('Be as causious and as fiercely critical as possible.'),
             tag.li('Point out errors or deficiencies in the thinking process.'),
             tag.li('Question the strength of the evidence.'),
             tag.li('What are the risks?'),
         ]
         
         li.append(tag.li('In order to get the full value from any suggestion or idea, it is important that the black hat be done thoroughly:', tag.ul(*sub_li)))
         li.extend([
             tag.li('Black hat thinking is not argument and must not be allowed to degenerate into argument.'),
             tag.li(tag.strong('Caution:'), ' There are people who overuse the black hat and who spend all their time trying to find fault. The fault is not in the black hat but in the abuse, overuse or misuse of the black hat.')
         ])
         
         tags.append(tag.ul(*li))
         
         tags.append(self.expand_macro(formatter, name, 'yellow,size=m'))
         
         li = [
             tag.li('The yellow hat is optimistic and logical (positive judgements).')
         ]
         
         sub_li = [ 
             tag.li('The generation of proposals.'),
             tag.li('The positive assessment of proposals.'),
             tag.li("Developing or 'building up' of proposals.")
         ]
         
         li.append(tag.li('The yellow hat is concerned with:', tag.ol(*sub_li)))
         li.extend([
             tag.li('Under the yellow hat a thinker deliberatly sets out to find whatever benefit there may be in a suggestion.'),
             tag.li('It is a waste of time setting out to be creative if you are not going to recognize a good idea.'),
             tag.li('Value and benefit are by no means always obvious.'),
             tag.li('Since the yellow hat is logical you should give a reason for the value you put forward.'),
             tag.li('The emphasis of yellow hat thinking is on exploration and positive speculation, oppertunity seeking.'),
             tag.li("Yellow hat thinking is concerned with the positive attitude of getting the job done, let's make it happen.")
         ])
         
         tags.append(tag.ul(*li))
         
         tags.append(self.expand_macro(formatter, name, 'green,size=m'))
         
         li = [
             tag.li('The green hat is creative, sometimes illogical.'),
             tag.li('The green hat is concerned with new ideas and new ways of looking at things, new perceptions.'),
             tag.li("Under the green hat we lay out options, alternatives and 'possibilities'."),
             tag.li('It corrects the faults found under the black hat and find noval ways the exploit the opportunities identified under the yellow hat.'),
             tag.li('You use the green hat to deliberately go after new ideas instead of waiting for them to come to you.'),
             tag.li('Sometimes you may be required to put forward provocations, illogical ideas, in order to provoke new concepts.'),
             tag.li('Under the green hat we use ideas as stepping stones, for their movement value, moving us to new ideas.'),
             tag.li('Use random words and ', tag.em('Po'), '.')
         ]
         
         tags.append(tag.ul(*li))
         
         tags.append(self.expand_macro(formatter, name, 'blue,size=m'))
         
         li = [
             tag.li('The blue hat is for meta-thinking, thinking about thinking.'),
             tag.li('Wearing the blue hat we are no longer thinking about the subject; instead, we are thinking about the thinking needed to explore the subject.'),
             tag.li('The blue hat thinker is like the conductor of an orchestra.'),
             tag.li("Generally the blue hat is worn by the facilitator, chairperson or leader of the session, it's a permanent role."),
             tag.li('The blue hat is for the organization and management of thinking, it also controls the process of thinking.'),
             tag.li('The initial blue hat defines the problem, list constraints and sets the agenda, the sequence of the other hats to be used.'),
             tag.li('Blue hat thinking stops arguments, enforces the discipline and keep people focussed on map making.'),
             tag.li('The final blue hat is responsible for summaries, overviews and conclusions.')
         ]
         
         tags.append(tag.ul(*li))
         
         fedoras = tag.a('fedoras', href=get_absolute_url(formatter.href.base, 'htdocs://sixhats/img/source/fedoras.svg'))
         hardhats = tag.a('hardhats', href=get_absolute_url(formatter.href.base, 'htdocs://sixhats/img/source/hardhats.svg'))
         tophats = tag.a('tophats', href=get_absolute_url(formatter.href.base, 'htdocs://sixhats/img/source/tophats.svg'))
         
         tags.append(tag.p('PS. If you wish to use any of these images in your own documents rather use the high quality vectors: ', fedoras, ', ', hardhats, ' and ', tophats, '.'))
         
         if hide:
             add_script(formatter.req, 'sixhats/js/hide.js')
             
             if hide.lower() == 'hide':
                 return ''.join([str(i) for i in ('- ', tag.a(id='hide', href='#', style='font-size: 8pt;')('show six hats introduction'), ' -', tag.div(id='introduction', style='display: none;', *tags))])
             else:
                 return ''.join([str(i) for i in ('- ', tag.a(id='hide', href='#', style='font-size: 8pt;')('hide six hats introduction'), ' -', tag.div(id='introduction', *tags))])
         else:
             return tag.div(id='introduction', *tags)
     
     
     id = kwargs.get('id', squish_string(title))
     size = kwargs.get('size', 'large')
     type = kwargs.get('type', 'hardhat').lower()
     h = kwargs.get('h')
     
     if type in ('fedora', 'hardhat', 'tophat'):
         if size.endswith('%'):
             percentage = float(size.strip('%')) / 100.0
             width, height = SIZES[type]['l']
         else:
             percentage = 1
             width, height = SIZES[type][size[0]]
         
         width = int(width * percentage)
         height = int(height * percentage)
     
     if h:
         if h == '1':
             root = tag.h1
         elif h == '2':
             root = tag.h2
         elif h == '3':
             root = tag.h3
         elif h == '4':
             root = tag.h4
         else:
             root = tag.h5
     else:
         s0 = size[0]
         if s0 == 'l':
             root = tag.h1
         elif s0 == 'm':
             root = tag.h2
         elif s0 == 's':
             root = tag.h3
         else:
             root = tag.h1
     
     url = get_absolute_url(formatter.href.base, 'htdocs://sixhats/img/%(type)s/%(hat)s.jpg' % {'type': type, 'hat': hat})
     
     if id:
         return root(id=id)(tag.img(src=url, width=width, height=height), title)
     else:
         return root()(tag.img(src=url, width=width, height=height), title)
Exemple #14
0
    def expand_macro(self, formatter, name, args):
        context = formatter.context
        resource = formatter.context.resource
        
        # Bail out if we are in a no-float zone
        if hasattr(formatter, 'properties') and \
               'macro_no_float' in formatter.properties:
            return ''
        
        current_page = resource.id
         
        # Split the args
        args, kw = parse_args(args)
        # Options
        inline = False
        pagenames = []
        
        default_heading = 'Table of Contents'
        params = {'min_depth': 1, 'max_depth': 6}
        # Global options
        for arg in args:
            arg = arg.strip()
            if arg == 'inline':
                inline = True
            elif arg == 'noheading':
                default_heading = ''
            elif arg == 'notitle':
                params['min_depth'] = 2     # Skip page title
            elif (arg == 'titleindex') or (arg == 'sectionindex'):
                # sectionindex is a page-context sensitive titleindex
                if arg == 'sectionindex':
                    params['section_index'] = True
                params['title_index'] = True
                default_heading = default_heading and 'Page Index'
            elif arg == 'nofloat':
                return ''
            elif arg != '':
                pagenames.append(arg)
        heading = kw.pop('heading', '') or default_heading

        if 'depth' in kw:
           params['max_depth'] = int(kw['depth'])

        # Has the user supplied a list of pages?
        if not pagenames:
            # Be sure to test section_index first as title_index is also true in this case
            if 'section_index' in params:
                # Use 'parent' of current page (level delimiter is /), if any
                toks = re.match('^(?P<parent>.*)/[^/]*$',current_page)
                if toks:
                    pagenames.append(toks.group('parent')+'/')
                else:
                    pagenames.append('*')
            elif 'title_index' in params:
                pagenames.append('*')       # A marker for 'all'
            else:
                pagenames.append(current_page)
                params['root'] = ''
                params['min_depth'] = 2     # Skip page title
        # Check for wildcards and expand lists
        temp_pagenames = []
        for pagename in pagenames:
            if 'section_index' in params:
                # / is considered an equivalent to * in sectionindex
                if pagename == '/':
                    pagename = '*'
                if not pagename.endswith('*'):
                    pagename += '*'
            if pagename.endswith('*'):
                temp_pagenames.extend(sorted(
                        WikiSystem(self.env).get_pages(pagename[:-1])))
            else:
                temp_pagenames.append(pagename)
        pagenames = temp_pagenames

        base = tag.div(class_=inline and 'wiki-toc-inline' or 'wiki-toc')
        ol = tag.ol()
        base.append([heading and tag.h4(heading), ol])

        active = len(pagenames) > 1
        for pagename in pagenames:
            page_resource = resource(id=pagename)
            if not 'WIKI_VIEW' in context.perm(page_resource):
                # Not access to the page, so should not be included
                continue
            if 'title_index' in params:
                self._render_title_index(formatter, ol, page_resource,
                            active and pagename == current_page,
                            params['min_depth'] < 2)
            else:
                self._render_page_outline(formatter, ol, page_resource,
                                                        active, params)
        return base