import os import re import MooseDocs from MooseDocs import common from MooseDocs.base import components from MooseDocs.extensions import core, floats, heading from MooseDocs.tree import tokens def make_extension(**kwargs): return AutoLinkExtension(**kwargs) PAGE_LINK_RE = re.compile(r'(?P<filename>.*?\.md)?(?P<bookmark>#.*)?', flags=re.UNICODE) LocalLink = tokens.newToken('LocalLink', bookmark=u'') AutoLink = tokens.newToken('AutoLink', page=u'', bookmark=u'') class AutoLinkExtension(components.Extension): """ Extension that replaces the default Link and LinkShortcut behavior and handles linking to other files. This includes the ability to extract the content from the linked page (i.e., headers) for display on the current page. """ @staticmethod def defaultConfig(): config = components.Extension.defaultConfig() return config def extend(self, reader, renderer):
#* #* Licensed under LGPL 2.1, please see LICENSE for details #* https://www.gnu.org/licenses/lgpl-2.1.html """Test for the Reader objects.""" import unittest import re import logging logging.basicConfig()#level=logging.CRITICAL) import MooseDocs from MooseDocs.common import exceptions from MooseDocs.tree import tokens, pages from MooseDocs.base import readers, lexers, components Word = tokens.newToken('Word') class WordComponent(components.TokenComponent): RE = re.compile('(?P<inline>\w+)\s*') def createToken(self, parent, info, page): if info['inline'] == 'throw': raise Exception("testing") return Word(parent) Letter = tokens.newToken('Letter', content=u'') class LetterComponent(components.TokenComponent): RE = re.compile('(?P<content>\w)') def createToken(self, parent, info, page): return Letter(parent, content=info['content']) class TestReader(unittest.TestCase):
from MooseDocs.base import components, renderers, Translator from MooseDocs.common import exceptions from MooseDocs.tree import tokens, html, latex LOG = logging.getLogger(__name__) def make_extension(**kwargs): """ Create and return the CoreExtension object for converting from markdown to html/latex. """ return CoreExtension(**kwargs) Section = tokens.newToken('Section') Word = tokens.newToken('Word', content='') Space = tokens.newToken('Space', count=1) Break = tokens.newToken('Break', count=1) Punctuation = tokens.newToken('Punctuation', content='') Number = tokens.newToken('Number', content='') Code = tokens.newToken('Code', content='', language='text', escape=True) Heading = tokens.newToken('Heading', level=1) Paragraph = tokens.newToken('Paragraph') OrderedList = tokens.newToken('OrderedList', browser_default=True, start=1) UnorderedList = tokens.newToken('UnorderedList', browser_default=True) ListItem = tokens.newToken('ListItem') Link = tokens.newToken('Link', url='') Shortcut = tokens.newToken('Shortcut', key='', link='', prefix='') ShortcutLink = tokens.newToken('ShortcutLink', key='') Monospace = tokens.newToken('Monospace', content='')
import os import uuid import collections import logging import mooseutils from MooseDocs.common import exceptions from MooseDocs.base import components, LatexRenderer from MooseDocs.tree import pages, tokens, html, latex from MooseDocs.extensions import core, command, heading LOG = logging.getLogger(__name__) def make_extension(**kwargs): return ContentExtension(**kwargs) ContentToken = tokens.newToken('ContentToken', location=u'', level=None) AtoZToken = tokens.newToken('AtoZToken', location=u'', level=None, buttons=bool) LATEX_CONTENTLIST = """ \\DeclareDocumentCommand{\\ContentItem}{mmm}{#3 (\\texttt{\\small #1})\\dotfill \\pageref{#2}\\\\} """ class ContentExtension(command.CommandExtension): """ Allows for the creation of markdown contents lists. """ LETTER = 10 FOLDER = 11 @staticmethod def defaultConfig():
import MooseDocs from MooseDocs import common from MooseDocs.base import components from MooseDocs.extensions import core, floats, heading from MooseDocs.tree import tokens def make_extension(**kwargs): return AutoLinkExtension(**kwargs) PAGE_LINK_RE = re.compile(r'(?P<filename>.*?\.md)?(?P<bookmark>#.*)?', flags=re.UNICODE) LocalLink = tokens.newToken('LocalLink', bookmark=u'') AutoLink = tokens.newToken('AutoLink', page=u'', bookmark=u'') class AutoLinkExtension(components.Extension): """ Extension that replaces the default Link and LinkShortcut behavior and handles linking to other files. This includes the ability to extract the content from the linked page (i.e., headers) for display on the current page. """ @staticmethod def defaultConfig(): config = components.Extension.defaultConfig() return config def extend(self, reader, renderer):
#* #* All rights reserved, see COPYRIGHT for full restrictions #* https://github.com/idaholab/moose/blob/master/COPYRIGHT #* #* Licensed under LGPL 2.1, please see LICENSE for details #* https://www.gnu.org/licenses/lgpl-2.1.html from MooseDocs.common import exceptions from MooseDocs.base import components from MooseDocs.extensions import core, command, materialicon from MooseDocs.tree import tokens, html, latex def make_extension(**kwargs): return LayoutExtension(**kwargs) ColumnToken = tokens.newToken('ColumnToken', width=u'', small=12, medium=12, large=12) RowToken = tokens.newToken('RowToken') class LayoutExtension(command.CommandExtension): """ Adds ability to create row and column layouts. """ @staticmethod def defaultConfig(): config = command.CommandExtension.defaultConfig() config['use-title-prefix'] = (True, "Enable/disable including the brand (e.g., ERROR) as " \ "prefix for the alert title.") return config def extend(self, reader, renderer):
#!/usr/bin/env python2 #* This file is part of the MOOSE framework #* https://www.mooseframework.org #* #* All rights reserved, see COPYRIGHT for full restrictions #* https://github.com/idaholab/moose/blob/master/COPYRIGHT #* #* Licensed under LGPL 2.1, please see LICENSE for details #* https://www.gnu.org/licenses/lgpl-2.1.html import unittest from MooseDocs.tree import tokens Test = tokens.newToken('Test', foo='bar') class TestTokens(unittest.TestCase): def testToken(self): token = Test(None) self.assertEqual(token.name, 'Test') self.assertTrue(token['recursive']) self.assertEqual(token['foo'], 'bar') token = Test(None, recursive=False, foo='foo') self.assertFalse(token['recursive']) self.assertEqual(token['foo'], 'foo') if __name__ == '__main__': unittest.main(verbosity=2)
def extend(self, reader, renderer): self.requires(core, command) self.addCommand(reader, BibtexCommand()) self.addCommand(reader, BibtexReferenceComponent()) reader.addInline(BibtexReferenceComponentDeprecated(), location='>FormatInline') renderer.add('BibtexCite', RenderBibtexCite()) renderer.add('BibtexBibliography', RenderBibtexBibliography()) if isinstance(renderer, LatexRenderer): renderer.addPackage('natbib', 'round') BibtexCite = tokens.newToken('BibtexCite', keys=[]) BibtexBibliography = tokens.newToken('BibtexBibliography', bib_style=u'') class BibtexReferenceComponent(command.CommandComponent): COMMAND = ('cite', 'citet', 'citep', 'nocite') SUBCOMMAND = None def createToken(self, parent, info, page): keys = [key.strip() for key in info['inline'].split(',')] BibtexCite(parent, keys=keys, cite=info['command']) self.extension.addCitations(*keys) return parent class BibtexReferenceComponentDeprecated(components.TokenComponent):
from MooseDocs.common import exceptions from MooseDocs.base import components, LatexRenderer from MooseDocs.tree import html, tokens, syntax, latex, app_syntax from MooseDocs.extensions import core, floats, table, autolink, materialicon from MooseDocs.extensions import command LOG = logging.getLogger(__name__) def make_extension(**kwargs): return AppSyntaxExtension(**kwargs) InputParametersToken = tokens.newToken('InputParametersToken', parameters=dict(), level=2, groups=list(), hide=set(), show=set(), visible=set()) ParameterToken = tokens.newToken('ParameterToken', inline=False, parameter=None, description=True, default=True, options=True, cpp_type=True) SyntaxList = tokens.newToken('SyntaxList') SyntaxListItem = tokens.newToken('SyntaxListItem', syntax=u'', group=u'', header=False) SyntaxLink = tokens.newToken('SyntaxLink', core.Link) LATEX_PARAMETER = """
#* All rights reserved, see COPYRIGHT for full restrictions #* https://github.com/idaholab/moose/blob/master/COPYRIGHT #* #* Licensed under LGPL 2.1, please see LICENSE for details #* https://www.gnu.org/licenses/lgpl-2.1.html import importlib from MooseDocs.base import LatexRenderer from MooseDocs.common import exceptions from MooseDocs.tree import tokens, latex from MooseDocs.extensions import core, floats, command, table def make_extension(**kwargs): return DevelExtension(**kwargs) ExampleFloat = tokens.newToken('ExampleFloat', floats.Float) EXAMPLE_LATEX = """ \\newtcolorbox [auto counter,number within=chapter]{example}[2][]{% skin=bicolor,colback=black!10,colbacklower=white,colframe=black!90,fonttitle=\\bfseries, title=Example~\\thetcbcounter: #2,#1} """ class DevelExtension(command.CommandExtension): """ Adds features useful for MooseDocs developers such as example blocks and settings tables. """ @staticmethod def defaultConfig(): config = command.CommandExtension.defaultConfig()
#* #* All rights reserved, see COPYRIGHT for full restrictions #* https://github.com/idaholab/moose/blob/master/COPYRIGHT #* #* Licensed under LGPL 2.1, please see LICENSE for details #* https://www.gnu.org/licenses/lgpl-2.1.html from MooseDocs.base import components, renderers from MooseDocs.common import exceptions from MooseDocs.extensions import command from MooseDocs.tree import tokens, html, latex def make_extension(**kwargs): return StyleExtension(**kwargs) StyleToken = tokens.newToken('StyleToken', halign='left', color=None, border=0) class StyleExtension(command.CommandExtension): @staticmethod def defaultConfig(): config = command.CommandExtension.defaultConfig() return config def extend(self, reader, renderer): self.requires(command) self.addCommand(reader, StyleCommand()) renderer.add('StyleToken', RenderStyleToken()) if isinstance(renderer, renderers.LatexRenderer): renderer.addPackage(u'xcolor')
#* Licensed under LGPL 2.1, please see LICENSE for details #* https://www.gnu.org/licenses/lgpl-2.1.html import os import re import uuid import mooseutils from MooseDocs import common from MooseDocs.extensions import command, floats from MooseDocs.base import components, renderers from MooseDocs.tree import tokens, html def make_extension(**kwargs): return PlotlyExtension(**kwargs) ScatterToken = tokens.newToken('ScatterToken', data=[], layout=dict()) class PlotlyExtension(command.CommandExtension): """ Extension for creating graphs via Plotly: https://plot.ly """ @staticmethod def defaultConfig(): config = command.CommandExtension.defaultConfig() config['prefix'] = (u'Figure', "The caption prefix (e.g., Fig.).") return config def extend(self, reader, renderer): self.requires(command, floats) self.addCommand(reader, PlotlyScatter())
import re import uuid import anytree from MooseDocs.base import components, renderers from MooseDocs.common import exceptions from MooseDocs.tree import tokens, html, latex from MooseDocs.extensions import core, floats def make_extension(**kwargs): """Create an instance of the Extension object.""" return KatexExtension(**kwargs) LatexBlockEquation = tokens.newToken('LatexBlockEquation', tex=r'', label=u'', number=None, numbered=True, bookmark=None) LatexInlineEquation = tokens.newToken('LatexInlineEquation', tex=r'', bookmark=None) class KatexExtension(components.Extension): """ Extension object for parsing and rendering LaTeX equations with KaTeX. """ @staticmethod def defaultConfig(): config = components.Extension.defaultConfig() config['prefix'] = ('Eq.', r"The prefix to used when referring to an equation by " \ r"the \\label content.") config['macros'] = (None, "Macro definitions to apply to equations.") return config
#* https://github.com/idaholab/moose/blob/master/COPYRIGHT #* #* Licensed under LGPL 2.1, please see LICENSE for details #* https://www.gnu.org/licenses/lgpl-2.1.html import re import MooseDocs from MooseDocs.base import components, LatexRenderer from MooseDocs.extensions import command, floats from MooseDocs.tree import html, tokens, latex def make_extension(**kwargs): return TableExtension(**kwargs) Table = tokens.newToken('Table', form=[]) TableBody = tokens.newToken('TableBody') TableHead = tokens.newToken('TableHead') TableHeadItem = tokens.newToken('TableHeadItem') TableRow = tokens.newToken('TableRow') TableItem = tokens.newToken('TableItem', align='center') TableFloat = tokens.newToken('TableFloat', floats.Float) def builder(rows, headings=None, form=None): """Helper for creating tokens for a table.""" node = Table(None) if headings: thead = TableHead(node) row = TableRow(thead) for h in headings: th = TableHeadItem(row, align='left')
#* https://www.mooseframework.org #* #* All rights reserved, see COPYRIGHT for full restrictions #* https://github.com/idaholab/moose/blob/master/COPYRIGHT #* #* Licensed under LGPL 2.1, please see LICENSE for details #* https://www.gnu.org/licenses/lgpl-2.1.html from MooseDocs.base import components, LatexRenderer from MooseDocs.tree import html, tokens, latex from MooseDocs.extensions import command, core def make_extension(**kwargs): return MaterialIconExtension(**kwargs) Icon = tokens.newToken('Icon', icon=u'', faicon=u'') class MaterialIconExtension(command.CommandExtension): "Adds ability to include material icons.""" @staticmethod def defaultConfig(): config = components.Extension.defaultConfig() return config def extend(self, reader, renderer): self.requires(command) self.addCommand(reader, IconCommand()) renderer.add('Icon', RenderIcon()) if isinstance(renderer, LatexRenderer):
#* #* All rights reserved, see COPYRIGHT for full restrictions #* https://github.com/idaholab/moose/blob/master/COPYRIGHT #* #* Licensed under LGPL 2.1, please see LICENSE for details #* https://www.gnu.org/licenses/lgpl-2.1.html import re from MooseDocs.base import components from MooseDocs.tree import tokens def make_extension(**kwargs): return CommentExtension(**kwargs) Comment = tokens.newToken('Comment', content='') class CommentExtension(components.Extension): """ Extracts the heading from AST after tokenization. """ @staticmethod def defaultConfig(): config = components.Extension.defaultConfig() return config def extend(self, reader, renderer): reader.addInline(HTMLCommentBlock(), location='_begin') reader.addInline(CommentInline(), location='_begin') reader.addBlock(CommentBlock(), location='_begin')
import anytree from MooseDocs.base import components, renderers, Translator from MooseDocs.common import exceptions from MooseDocs.tree import tokens, html, latex LOG = logging.getLogger(__name__) def make_extension(**kwargs): """ Create and return the CoreExtension object for converting from markdown to html/latex. """ return CoreExtension(**kwargs) Section = tokens.newToken(u'Section') Word = tokens.newToken(u'Word', content=u'') Space = tokens.newToken(u'Space', count=1) Break = tokens.newToken(u'Break', count=1) Punctuation = tokens.newToken(u'Punctuation', content=u'') Number = tokens.newToken(u'Number', content=u'') Code = tokens.newToken(u'Code', content=u'', language=u'text', escape=True) Heading = tokens.newToken(u'Heading', level=1) Paragraph = tokens.newToken(u'Paragraph') OrderedList = tokens.newToken(u'OrderedList', browser_default=True, start=1) UnorderedList = tokens.newToken(u'UnorderedList', browser_default=True) ListItem = tokens.newToken(u'ListItem') Link = tokens.newToken(u'Link', url=u'') Shortcut = tokens.newToken(u'Shortcut', key=u'', link=u'', prefix=u'') ShortcutLink = tokens.newToken(u'ShortcutLink', key=u'') Monospace = tokens.newToken(u'Monospace', content=u'')
import MooseDocs from MooseDocs import common from MooseDocs.base import components from MooseDocs.extensions import core, floats, heading from MooseDocs.tree import tokens, latex def make_extension(**kwargs): return AutoLinkExtension(**kwargs) PAGE_LINK_RE = re.compile(r'(?P<filename>.*?\.md)?(?P<bookmark>#.*)?', flags=re.UNICODE) LOG = logging.getLogger(__name__) SourceLink = tokens.newToken('SourceLink') LocalLink = tokens.newToken('LocalLink', bookmark=u'') AutoLink = tokens.newToken('AutoLink', page=u'', bookmark=u'', optional=False, warning=False, exact=False) class AutoLinkExtension(components.Extension): """ Extension that replaces the default Link and LinkShortcut behavior and handles linking to other files. This includes the ability to extract the content from the linked page (i.e., headers) for display on the current page. """
#* #* Licensed under LGPL 2.1, please see LICENSE for details #* https://www.gnu.org/licenses/lgpl-2.1.html import re import logging from MooseDocs.base import renderers, components from MooseDocs.tree import html, tokens from MooseDocs.extensions import core, command LOG = logging.getLogger(__name__) def make_extension(**kwargs): """Create an instance of the Extension object.""" return RevealExtension(**kwargs) Section = tokens.newToken('Section') SubSection = tokens.newToken('SubSection') Notes = tokens.newToken('Notes') class RevealExtension(command.CommandExtension): """ Presentation extension using Reveal.js """ @staticmethod def defaultConfig(): config = command.CommandExtension.defaultConfig() return config def initMetaData(self, page, meta): meta.initData('pdf-active', True)
import MooseDocs from MooseDocs import common from MooseDocs.base import components, LatexRenderer from MooseDocs.tree import html, tokens, syntax, latex, app_syntax from MooseDocs.extensions import core, floats, table, autolink, materialicon from MooseDocs.extensions import command LOG = logging.getLogger(__name__) def make_extension(**kwargs): return AppSyntaxExtension(**kwargs) ParameterToken = tokens.newToken('ParameterToken', parameter=None) InputParametersToken = tokens.newToken('InputParametersToken', parameters=dict(), level=2, groups=list(), hide=list(), show=list(), visible=list()) SyntaxList = tokens.newToken('SyntaxList') SyntaxListItem = tokens.newToken('SyntaxListItem', syntax='', group='', header=False) SyntaxLink = tokens.newToken('SyntaxLink', core.Link)
#* https://github.com/idaholab/moose/blob/master/COPYRIGHT #* #* Licensed under LGPL 2.1, please see LICENSE for details #* https://www.gnu.org/licenses/lgpl-2.1.html import os import uuid import mooseutils from MooseDocs.base import components from MooseDocs.tree import pages, tokens, html from MooseDocs.extensions import core, command, heading def make_extension(**kwargs): return ContentExtension(**kwargs) Collapsible = tokens.newToken('Collapsible', summary=u'') ContentToken = tokens.newToken('ContentToken', location=u'') AtoZToken = tokens.newToken('AtoZToken', location=u'', level=None, buttons=bool) class ContentExtension(command.CommandExtension): """ Allows for the creation of markdown contents lists. """ @staticmethod def defaultConfig(): config = command.CommandExtension.defaultConfig() return config def extend(self, reader, renderer): self.requires(core, heading, command) self.addCommand(reader, ContentCommand())
""" Test LexerInformation class that stores parsing data. """ def testInfo(self): regex = re.compile(r'(?P<key>foo)') match = regex.search('foo bar') pattern = lexers.Pattern(name='name', regex=regex, function=Proxy()) info = lexers.LexerInformation(match=match, pattern=pattern, line=42) self.assertEqual(info.line, 42) self.assertEqual(info.pattern, 'name') self.assertEqual(list(info.keys()), [0, 1, 'key']) self.assertIn('key', info) self.assertIn('line:42', str(info)) FooBar = tokens.newToken('FooBar', content='') class FooBarComponent(object): """Class for testing lexer.""" def __call__(self, parent, info, page): content = info['content'] if content in ('foo', 'bar'): return FooBar(parent, content=content) class WordComponent(object): """Class for testing lexer.""" def __call__(self, parent, info, page): return core.Word(parent, content=info['content']) class TestLexer(unittest.TestCase): """ Test basic operation of Lexer class.
#* #* Licensed under LGPL 2.1, please see LICENSE for details #* https://www.gnu.org/licenses/lgpl-2.1.html import os import logging from MooseDocs.common import exceptions from MooseDocs.base import components, LatexRenderer from MooseDocs.extensions import command, floats from MooseDocs.tree import tokens, html, latex LOG = logging.getLogger(__name__) def make_extension(**kwargs): return MediaExtension(**kwargs) Image = tokens.newToken('Image', src=u'', tex=u'') Video = tokens.newToken('Video', src=u'', tex=u'', controls=True, autoplay=True, loop=True, tstart=None, tstop=None) class MediaExtensionBase(command.CommandExtension): def latexImage(self, parent, token, page, src): args = [] style = latex.parse_style(token) width = style.get('width', None) if width: if width.endswith('%'): width = u'{}\\textwidth'.format(int(width[:-1])/100.) args.append(latex.Bracket(string=u'width={}'.format(width), escape=False))
try: import plotly HAVE_PYTHON_PLOTLY = True except ImportError: HAVE_PYTHON_PLOTLY = False import mooseutils from MooseDocs import common from MooseDocs.extensions import command, floats from MooseDocs.base import components, renderers from MooseDocs.tree import tokens, html, latex def make_extension(**kwargs): return GraphExtension(**kwargs) ScatterToken = tokens.newToken('ScatterToken', data=[], layout=dict()) class GraphExtension(command.CommandExtension): """ Extension for creating graphs via Plotly: https://plot.ly """ @staticmethod def defaultConfig(): config = command.CommandExtension.defaultConfig() config['prefix'] = ('Figure', "The caption prefix (e.g., Fig.).") config['draft'] = (False, "Enable draft mode for LaTeX output.") return config def extend(self, reader, renderer): self.requires(command, floats)
#* https://www.mooseframework.org #* #* All rights reserved, see COPYRIGHT for full restrictions #* https://github.com/idaholab/moose/blob/master/COPYRIGHT #* #* Licensed under LGPL 2.1, please see LICENSE for details #* https://www.gnu.org/licenses/lgpl-2.1.html from MooseDocs.base import components from MooseDocs.tree import html, tokens from MooseDocs.extensions import command def make_extension(**kwargs): return MaterialIconExtension(**kwargs) IconBlockToken = tokens.newToken('IconBlockToken') IconToken = tokens.newToken('IconToken', icon=u'') class MaterialIconExtension(command.CommandExtension): "Adds ability to include material icons.""" @staticmethod def defaultConfig(): config = components.Extension.defaultConfig() return config def extend(self, reader, renderer): self.requires(command) self.addCommand(reader, IconCommand()) renderer.add('IconToken', RenderIconToken()) renderer.add('IconBlockToken', RenderIconBlockToken())
from MooseDocs.tree import html, tokens, syntax, latex, app_syntax from MooseDocs.extensions import core, floats, table, autolink, materialicon from MooseDocs.extensions import command LOG = logging.getLogger(__name__) def make_extension(**kwargs): return AppSyntaxExtension(**kwargs) InputParametersToken = tokens.newToken('InputParametersToken', parameters=dict(), level=2, groups=list(), hide=list(), show=list(), visible=list()) ParameterToken = tokens.newToken('ParameterToken', inline=False, parameter=None, description=True, default=True, options=True, cpp_type=True) SyntaxList = tokens.newToken('SyntaxList') SyntaxListItem = tokens.newToken('SyntaxListItem', syntax=u'', group=u'', header=False)
#* #* Licensed under LGPL 2.1, please see LICENSE for details #* https://www.gnu.org/licenses/lgpl-2.1.html import os import mooseutils import MooseDocs from MooseDocs.base import LatexRenderer from MooseDocs import common from MooseDocs.common import exceptions from MooseDocs.extensions import core, command, floats from MooseDocs.tree import tokens, latex Listing = tokens.newToken('Listing', floats.Float) ListingCode = tokens.newToken('ListingCode', core.Code) ListingLink = tokens.newToken('ListingLink', core.Link) def make_extension(**kwargs): return ListingExtension(**kwargs) class ListingExtension(command.CommandExtension): """ Provides !listing command for including source code from files. """ @staticmethod def defaultConfig(): config = command.CommandExtension.defaultConfig() config['prefix'] = (u'Listing', "The caption prefix (e.g., Fig.).")
#* https://www.gnu.org/licenses/lgpl-2.1.html import re import codecs import logging import moosetree import MooseDocs from MooseDocs import common from MooseDocs.common import exceptions from MooseDocs.base import components from MooseDocs.extensions import core, command, include, alert, floats, materialicon from MooseDocs.tree import tokens LOG = logging.getLogger(__name__) TemplateItem = tokens.newToken('TemplateItem', key='') TemplateField = tokens.newToken('TemplateField', key='', required=True) TemplateSubField = tokens.newToken('TemplateSubField') def make_extension(**kwargs): return TemplateExtension(**kwargs) class TemplateExtension(include.IncludeExtension): """ Creates a means for building template markdown files. This class inherits from the IncludeExtension to exploit the page dependency functions. """ @staticmethod
from MooseDocs.common import exceptions from MooseDocs.base import components from MooseDocs.tree import html, tokens, syntax, app_syntax from MooseDocs.extensions import core, floats, autolink, materialicon from MooseDocs.extensions import command LOG = logging.getLogger(__name__) def make_extension(**kwargs): return AppSyntaxExtension(**kwargs) InputParametersToken = tokens.newToken('InputParametersToken', parameters=dict(), level=2, groups=list(), hide=set(), show=set(), visible=set()) SyntaxList = tokens.newToken('SyntaxList') SyntaxListItem = tokens.newToken('SyntaxListItem', header=False) DatabaseListToken = tokens.newToken('DatabaseListToken', level=2) class AppSyntaxExtension(command.CommandExtension): @staticmethod def defaultConfig(): config = command.CommandExtension.defaultConfig() config['executable'] = (None, "The MOOSE application executable to use for generating syntax.")
#* #* All rights reserved, see COPYRIGHT for full restrictions #* https://github.com/idaholab/moose/blob/master/COPYRIGHT #* #* Licensed under LGPL 2.1, please see LICENSE for details #* https://www.gnu.org/licenses/lgpl-2.1.html import logging from MooseDocs.base import components from MooseDocs.extensions import command, core from MooseDocs.tree import tokens, html LOG = logging.getLogger(__name__) def make_extension(**kwargs): return GalleryExtension(**kwargs) Card = tokens.newToken('Card') CardImage = tokens.newToken('CardImage', src=u'') CardTitle = tokens.newToken('CardTitle') CardContent = tokens.newToken('CardContent') Gallery = tokens.newToken('Gallery', large=3, medium=6, small=12) class GalleryExtension(command.CommandExtension): """ Adds commands needed to create image galleries. """ @staticmethod def defaultConfig(): config = command.CommandExtension.defaultConfig() return config
import collections import logging import mooseutils from MooseDocs.common import exceptions from MooseDocs.base import components, LatexRenderer from MooseDocs.tree import pages, tokens, html, latex from MooseDocs.extensions import core, command, heading LOG = logging.getLogger(__name__) def make_extension(**kwargs): return ContentExtension(**kwargs) ContentToken = tokens.newToken('ContentToken', location=u'', level=None) AtoZToken = tokens.newToken('AtoZToken', location=u'', level=None, buttons=bool) LATEX_CONTENTLIST = """ \\DeclareDocumentCommand{\\ContentItem}{mmm}{#3 (\\texttt{\\small #1})\\dotfill \\pageref{#2}\\\\} """ class ContentExtension(command.CommandExtension): """ Allows for the creation of markdown contents lists. """ LETTER = 10
#* https://github.com/idaholab/moose/blob/master/COPYRIGHT #* #* Licensed under LGPL 2.1, please see LICENSE for details #* https://www.gnu.org/licenses/lgpl-2.1.html """Test for the Reader objects.""" import unittest import re import logging logging.basicConfig() #level=logging.CRITICAL) import MooseDocs from MooseDocs.common import exceptions from MooseDocs.tree import tokens, pages from MooseDocs.base import readers, lexers, components Word = tokens.newToken('Word') class WordComponent(components.ReaderComponent): RE = re.compile('(?P<inline>\w+)\s*') def createToken(self, parent, info, page): if info['inline'] == 'throw': raise Exception("testing") return Word(parent) Letter = tokens.newToken('Letter', content='') class LetterComponent(components.ReaderComponent):
self.addCommand(reader, SQATemplateItemCommand()) self.addCommand(reader, SQARequirementsCommand()) self.addCommand(reader, SQADocumentItemCommand()) self.addCommand(reader, SQACrossReferenceCommand()) self.addCommand(reader, SQARequirementsMatrixCommand()) self.addCommand(reader, SQAVerificationCommand()) renderer.add(SQATemplateItem, RenderSQATemplateItem()) renderer.add(SQARequirementMatrix, RenderSQARequirementMatrix()) renderer.add(SQARequirementMatrixItem, RenderSQARequirementMatrixItem()) renderer.add(SQARequirementMatrixHeading, RenderSQARequirementMatrixHeading()) SQADocumentItem = tokens.newToken('SQADocumentItem', key=u'') SQATemplateItem = tokens.newToken('SQATemplateItem', key=u'') SQARequirementMatrix = tokens.newToken('SQARequirementMatrix') SQARequirementMatrixItem = tokens.newToken('SQARequirementMatrixItem', label=u'', satisfied=True) SQARequirementMatrixHeading = tokens.newToken('SQARequirementMatrixHeading') SQAVandVMatrixItem = tokens.newToken('SQAVandVMatrixItem') SQARequirementCrossReference = tokens.newToken('SQARequirementCrossReference') class SQARequirementsCommand(command.CommandComponent): COMMAND = 'sqa' SUBCOMMAND = 'requirements' @staticmethod
#* #* Licensed under LGPL 2.1, please see LICENSE for details #* https://www.gnu.org/licenses/lgpl-2.1.html import os import mooseutils import MooseDocs from MooseDocs.base import LatexRenderer from MooseDocs import common from MooseDocs.common import exceptions from MooseDocs.extensions import core, command, floats from MooseDocs.tree import tokens, latex Listing = tokens.newToken('Listing', floats.Float) ListingCode = tokens.newToken('ListingCode', core.Code) ListingLink = tokens.newToken('ListingLink', core.Link) def make_extension(**kwargs): return ListingExtension(**kwargs) class ListingExtension(command.CommandExtension): """ Provides !listing command for including source code from files. """ @staticmethod def defaultConfig(): config = command.CommandExtension.defaultConfig()
#* https://www.mooseframework.org #* #* All rights reserved, see COPYRIGHT for full restrictions #* https://github.com/idaholab/moose/blob/master/COPYRIGHT #* #* Licensed under LGPL 2.1, please see LICENSE for details #* https://www.gnu.org/licenses/lgpl-2.1.html from MooseDocs.base import components from MooseDocs.extensions import core, command, materialicon from MooseDocs.tree import tokens, html def make_extension(**kwargs): return LayoutExtension(**kwargs) ColumnToken = tokens.newToken('ColumnToken', width=u'') RowToken = tokens.newToken('RowToken') class LayoutExtension(command.CommandExtension): """ Adds ability to create row and column layouts. """ @staticmethod def defaultConfig(): config = command.CommandExtension.defaultConfig() config['use-title-prefix'] = (True, "Enable/disable including the brand (e.g., ERROR) as " \ "prefix for the alert title.") return config def extend(self, reader, renderer):
#* All rights reserved, see COPYRIGHT for full restrictions #* https://github.com/idaholab/moose/blob/master/COPYRIGHT #* #* Licensed under LGPL 2.1, please see LICENSE for details #* https://www.gnu.org/licenses/lgpl-2.1.html from MooseDocs.base import components from MooseDocs.tree import html, tokens from MooseDocs.extensions import command def make_extension(**kwargs): return MaterialIconExtension(**kwargs) IconBlockToken = tokens.newToken('IconBlockToken') IconToken = tokens.newToken('IconToken', icon=u'') class MaterialIconExtension(command.CommandExtension): "Adds ability to include material icons." "" @staticmethod def defaultConfig(): config = components.Extension.defaultConfig() return config def extend(self, reader, renderer): self.requires(command) self.addCommand(reader, IconCommand()) renderer.add('IconToken', RenderIconToken())
#* Licensed under LGPL 2.1, please see LICENSE for details #* https://www.gnu.org/licenses/lgpl-2.1.html import os import uuid import mooseutils from MooseDocs.base import components from MooseDocs.tree import pages, tokens, html from MooseDocs.extensions import core, command, heading def make_extension(**kwargs): return ContentExtension(**kwargs) Collapsible = tokens.newToken('Collapsible', summary=u'') ContentToken = tokens.newToken('ContentToken', location=u'') AtoZToken = tokens.newToken('AtoZToken', location=u'', level=None, buttons=bool) class ContentExtension(command.CommandExtension): """ Allows for the creation of markdown contents lists. """ @staticmethod def defaultConfig(): config = command.CommandExtension.defaultConfig() return config
self.requires(core, command, alert, floats, core, materialicon) self.addCommand(reader, SQATemplateLoadCommand()) self.addCommand(reader, SQATemplateItemCommand()) self.addCommand(reader, SQARequirementsCommand()) self.addCommand(reader, SQADocumentItemCommand()) self.addCommand(reader, SQACrossReferenceCommand()) self.addCommand(reader, SQARequirementsMatrixCommand()) self.addCommand(reader, SQAVerificationCommand()) renderer.add(SQATemplateItem, RenderSQATemplateItem()) renderer.add(SQARequirementMatrix, RenderSQARequirementMatrix()) renderer.add(SQARequirementMatrixItem, RenderSQARequirementMatrixItem()) renderer.add(SQARequirementMatrixHeading, RenderSQARequirementMatrixHeading()) SQADocumentItem = tokens.newToken('SQADocumentItem', key=u'') SQATemplateItem = tokens.newToken('SQATemplateItem', key=u'') SQARequirementMatrix = tokens.newToken('SQARequirementMatrix') SQARequirementMatrixItem = tokens.newToken('SQARequirementMatrixItem', label=u'', satisfied=True) SQARequirementMatrixHeading = tokens.newToken('SQARequirementMatrixHeading') SQAVandVMatrixItem = tokens.newToken('SQAVandVMatrixItem') SQARequirementCrossReference = tokens.newToken('SQARequirementCrossReference') class SQARequirementsCommand(command.CommandComponent): COMMAND = 'sqa' SUBCOMMAND = 'requirements' @staticmethod def defaultSettings():
#* All rights reserved, see COPYRIGHT for full restrictions #* https://github.com/idaholab/moose/blob/master/COPYRIGHT #* #* Licensed under LGPL 2.1, please see LICENSE for details #* https://www.gnu.org/licenses/lgpl-2.1.html from MooseDocs.base import components from MooseDocs.extensions import core, command, materialicon from MooseDocs.tree import tokens, html def make_extension(**kwargs): return LayoutExtension(**kwargs) ColumnToken = tokens.newToken('ColumnToken', width=u'') RowToken = tokens.newToken('RowToken') class LayoutExtension(command.CommandExtension): """ Adds ability to create row and column layouts. """ @staticmethod def defaultConfig(): config = command.CommandExtension.defaultConfig() config['use-title-prefix'] = (True, "Enable/disable including the brand (e.g., ERROR) as " \ "prefix for the alert title.") return config def extend(self, reader, renderer):
return parent def create_modal_link(parent, title=None, content=None, string=None, **kwargs): """ Create the necessary tokens to create a link to a modal window with materialize. """ kwargs.setdefault('bookmark', unicode(uuid.uuid4())) link = core.Link(parent, url=u'#{}'.format(kwargs['bookmark']), class_='modal-trigger', string=string) create_modal(parent, title, content, **kwargs) return link Float = tokens.newToken('Float', img=False) Caption = tokens.newToken('Caption', key=u'', prefix=u'', number='?') ModalLink = tokens.newToken('ModalLink', bookmark=True, bottom=False, close=True) ModalLinkTitle = tokens.newToken('ModalLinkTitle') ModalLinkContent = tokens.newToken('ModalLinkContent') class FloatExtension(components.Extension): """ Provides ability to add caption float elements (e.g., figures, table, etc.). This is only a base extension. It does not provide tables for example, just the tools to make floats in a uniform manner. """ def extend(self, reader, renderer): renderer.add('Float', RenderFloat()) renderer.add('Caption', RenderCaption()) renderer.add('ModalLink', RenderModalLink())
return self.__database def extend(self, reader, renderer): self.requires(core, command) self.addCommand(reader, BibtexCommand()) self.addCommand(reader, BibtexReferenceComponent()) reader.addInline(BibtexReferenceComponentDeprecated(), location='>FormatInline') renderer.add('BibtexCite', RenderBibtexCite()) renderer.add('BibtexBibliography', RenderBibtexBibliography()) if isinstance(renderer, LatexRenderer): renderer.addPackage('natbib', 'round') BibtexCite = tokens.newToken('BibtexCite', keys=[]) BibtexBibliography = tokens.newToken('BibtexBibliography', bib_style=u'') class BibtexReferenceComponent(command.CommandComponent): COMMAND = ('cite', 'citet', 'citep', 'nocite') SUBCOMMAND = None def createToken(self, parent, info, page): keys = [key.strip() for key in info['inline'].split(',')] BibtexCite(parent, keys=keys, cite=info['command']) self.extension.addCitations(*keys) return parent class BibtexReferenceComponentDeprecated(components.TokenComponent): RE = re.compile(r'\[' # open r'(?P<cite>cite|citet|citep|nocite):' # cite prefix r'(?P<keys>.*?)' # list of keys
#* Licensed under LGPL 2.1, please see LICENSE for details #* https://www.gnu.org/licenses/lgpl-2.1.html from MooseDocs.common import exceptions from MooseDocs.base import components from MooseDocs.extensions import core, command, materialicon from MooseDocs.tree import tokens, html, latex def make_extension(**kwargs): return LayoutExtension(**kwargs) ColumnToken = tokens.newToken('ColumnToken', width='', small=12, medium=12, large=12) RowToken = tokens.newToken('RowToken') class LayoutExtension(command.CommandExtension): """ Adds ability to create row and column layouts. """ @staticmethod def defaultConfig(): config = command.CommandExtension.defaultConfig() config['use-title-prefix'] = (True, "Enable/disable including the brand (e.g., ERROR) as " \ "prefix for the alert title.") return config
#!/usr/bin/env python2 #* This file is part of the MOOSE framework #* https://www.mooseframework.org #* #* All rights reserved, see COPYRIGHT for full restrictions #* https://github.com/idaholab/moose/blob/master/COPYRIGHT #* #* Licensed under LGPL 2.1, please see LICENSE for details #* https://www.gnu.org/licenses/lgpl-2.1.html import unittest from MooseDocs.tree import tokens Test = tokens.newToken('Test', foo='bar') class TestTokens(unittest.TestCase): def testToken(self): token = Test(None) self.assertEqual(token.name, 'Test') self.assertTrue(token['recursive']) self.assertEqual(token['foo'], 'bar') token = Test(None, recursive=False, foo='foo') self.assertFalse(token['recursive']) self.assertEqual(token['foo'], 'foo') def testToDict(self): token = Test(None) self.assertEqual( token.toDict(), {
import re import uuid import moosetree from MooseDocs.base import components, renderers from MooseDocs.tree import tokens, html, latex from MooseDocs.extensions import command, core, floats def make_extension(**kwargs): """Create an instance of the Extension object.""" return KatexExtension(**kwargs) LatexBlockEquation = tokens.newToken('LatexBlockEquation', tex=r'', label=None, number=None, bookmark=None) LatexInlineEquation = tokens.newToken('LatexInlineEquation', tex=r'', bookmark=None) class KatexExtension(command.CommandExtension): """ Extension object for parsing and rendering LaTeX equations with KaTeX. """ @staticmethod def defaultConfig(): config = command.CommandExtension.defaultConfig() config['prefix'] = ('Eq.', r"The prefix to used when referring to an equation by " \
import MooseDocs from MooseDocs import common from MooseDocs.base import components from MooseDocs.extensions import core, floats, heading from MooseDocs.tree import tokens def make_extension(**kwargs): return AutoLinkExtension(**kwargs) PAGE_LINK_RE = re.compile(r'(?P<filename>.*?\.md)?(?P<bookmark>#.*)?', flags=re.UNICODE) LocalLink = tokens.newToken('LocalLink', bookmark=u'') AutoLink = tokens.newToken('AutoLink', page=u'', bookmark=u'', optional=False) class AutoLinkExtension(components.Extension): """ Extension that replaces the default Link and LinkShortcut behavior and handles linking to other files. This includes the ability to extract the content from the linked page (i.e., headers) for display on the current page. """ @staticmethod def defaultConfig(): config = components.Extension.defaultConfig() return config def extend(self, reader, renderer):
#* #* Licensed under LGPL 2.1, please see LICENSE for details #* https://www.gnu.org/licenses/lgpl-2.1.html import os from MooseDocs.base import components from MooseDocs.extensions import command, floats from MooseDocs.tree import tokens, html def make_extension(**kwargs): return MediaExtension(**kwargs) Image = tokens.newToken('Image', src=u'') Video = tokens.newToken('Video', src=u'', controls=True, autoplay=True, loop=True) class MediaExtension(command.CommandExtension): """ Extension for including images and movies, using the !media command. """ @staticmethod def defaultConfig(): config = components.Extension.defaultConfig() config['prefix'] = (u'Figure', "The caption prefix (e.g., Fig.).")
import anytree import mooseutils from MooseDocs import common from MooseDocs.common import exceptions from MooseDocs.base import components, renderers, LatexRenderer from MooseDocs.tree import pages, tokens, html, latex from MooseDocs.extensions import core, command, heading LOG = logging.getLogger(__name__) def make_extension(**kwargs): return ContentExtension(**kwargs) ContentToken = tokens.newToken('ContentToken', location=u'', level=None) AtoZToken = tokens.newToken('AtoZToken', location=u'', level=None, buttons=True) TableOfContents = tokens.newToken('TableOfContents', levels=list(), columns=1, hide=[]) LATEX_CONTENTLIST = """ \\DeclareDocumentCommand{\\ContentItem}{mmm}{#3 (\\texttt{\\small #1})\\dotfill \\pageref{#2}\\\\} """ class ContentExtension(command.CommandExtension):
import uuid import collections import anytree import MooseDocs from MooseDocs.common import exceptions from MooseDocs.base import components, LatexRenderer from MooseDocs.extensions import core from MooseDocs.tree import tokens, html, latex def make_extension(**kwargs): return FloatExtension(**kwargs) Float = tokens.newToken('Float', img=False, bottom=False, command=u'figure') FloatCaption = tokens.newToken('FloatCaption', key=u'', prefix=u'', number='?') ModalLink = tokens.newToken('ModalLink', bookmark=True, bottom=False, close=True) ModalLinkTitle = tokens.newToken('ModalLinkTitle') ModalLinkContent = tokens.newToken('ModalLinkContent') def create_float(parent, extension, reader, page, settings, bottom=False,
#* https://www.gnu.org/licenses/lgpl-2.1.html import collections from MooseDocs.base import components, renderers from MooseDocs.common import exceptions from MooseDocs.extensions import command, table, floats from MooseDocs.tree import tokens, html, latex def make_extension(**kwargs): return AcronymExtension(**kwargs) AcronymItem = collections.namedtuple('AcronymItem', 'key name used') AcronymToken = tokens.newToken('AcronymToken', acronym=u'') AcronymListToken = tokens.newToken('AcronymListToken', heading=True) class AcronymExtension(command.CommandExtension): """ Adds ability to create acronyms within the configuration and use them throughout the pages. """ @staticmethod def defaultConfig(): config = command.CommandExtension.defaultConfig() config['acronyms'] = (dict(), "Complete dict (or dict of dict) of acronyms.") return config def __init__(self, *args, **kwargs):
#* All rights reserved, see COPYRIGHT for full restrictions #* https://github.com/idaholab/moose/blob/master/COPYRIGHT #* #* Licensed under LGPL 2.1, please see LICENSE for details #* https://www.gnu.org/licenses/lgpl-2.1.html import os from MooseDocs.base import components from MooseDocs.extensions import command, floats from MooseDocs.tree import tokens, html def make_extension(**kwargs): return MediaExtension(**kwargs) Image = tokens.newToken('Image', src=u'') Video = tokens.newToken('Video', src=u'', controls=True, autoplay=True, loop=True) class MediaExtension(command.CommandExtension): """ Extension for including images and movies, using the !media command. """ @staticmethod def defaultConfig(): config = components.Extension.defaultConfig() config['prefix'] = (u'Figure', "The caption prefix (e.g., Fig.).") return config def extend(self, reader, renderer): self.requires(command, floats)
""" Test LexerInformation class that stores parsing data. """ def testInfo(self): regex = re.compile(r'(?P<key>foo)') match = regex.search('foo bar') pattern = lexers.Pattern(name='name', regex=regex, function=Proxy()) info = lexers.LexerInformation(match=match, pattern=pattern, line=42) self.assertEqual(info.line, 42) self.assertEqual(info.pattern, 'name') self.assertEqual(info.keys(), [0, 1, 'key']) self.assertIn('key', info) self.assertIn('line:42', str(info)) FooBar = tokens.newToken('FooBar', content=u'') class FooBarComponent(object): """Class for testing lexer.""" def __call__(self, parent, info, page): content = info['content'] if content in (u'foo', u'bar'): return FooBar(parent, content=content) class WordComponent(object): """Class for testing lexer.""" def __call__(self, parent, info, page): return core.Word(parent, content=info['content']) class TestLexer(unittest.TestCase): """ Test basic operation of Lexer class.
#* All rights reserved, see COPYRIGHT for full restrictions #* https://github.com/idaholab/moose/blob/master/COPYRIGHT #* #* Licensed under LGPL 2.1, please see LICENSE for details #* https://www.gnu.org/licenses/lgpl-2.1.html import os import MooseDocs from MooseDocs.base import components from MooseDocs.extensions import command from MooseDocs.tree import tokens, html def make_extension(**kwargs): return AlertExtension(**kwargs) AlertToken = tokens.newToken('AlertToken', brand=u'') AlertTitle = tokens.newToken('AlertTitle', brand=u'', prefix=True) AlertContent = tokens.newToken('AlertContent', brand=u'', icon=True) class AlertExtension(command.CommandExtension): """ Adds alert boxes (note, error, warning, and construction) to display important information. """ @staticmethod def defaultConfig(): config = command.CommandExtension.defaultConfig() config['use-title-prefix'] = (True, "Enable/disable including the brand (e.g., ERROR) as " \ "prefix for the alert title.") return config
import os import re import logging import MooseDocs from MooseDocs import common from MooseDocs.base import components from MooseDocs.extensions import core, floats, heading from MooseDocs.tree import tokens, latex def make_extension(**kwargs): return AutoLinkExtension(**kwargs) PAGE_LINK_RE = re.compile(r'(?P<filename>.*?\.md)?(?P<bookmark>#.*)?', flags=re.UNICODE) LOG = logging.getLogger(__name__) SourceLink = tokens.newToken('SourceLink') LocalLink = tokens.newToken('LocalLink', bookmark=u'') AutoLink = tokens.newToken('AutoLink', page=u'', bookmark=u'', optional=False) class AutoLinkExtension(components.Extension): """ Extension that replaces the default Link and LinkShortcut behavior and handles linking to other files. This includes the ability to extract the content from the linked page (i.e., headers) for display on the current page. """ @staticmethod def defaultConfig(): config = components.Extension.defaultConfig() return config
#* https://www.mooseframework.org #* #* All rights reserved, see COPYRIGHT for full restrictions #* https://github.com/idaholab/moose/blob/master/COPYRIGHT #* #* Licensed under LGPL 2.1, please see LICENSE for details #* https://www.gnu.org/licenses/lgpl-2.1.html from MooseDocs.base import components, LatexRenderer from MooseDocs.tree import html, tokens, latex from MooseDocs.extensions import command, core def make_extension(**kwargs): return MaterialIconExtension(**kwargs) Icon = tokens.newToken('Icon', icon='', faicon='') class MaterialIconExtension(command.CommandExtension): "Adds ability to include material icons.""" @staticmethod def defaultConfig(): config = components.Extension.defaultConfig() return config def extend(self, reader, renderer): self.requires(command) self.addCommand(reader, IconCommand()) renderer.add('Icon', RenderIcon()) if isinstance(renderer, LatexRenderer):
LOG = logging.getLogger(__name__) def make_extension(**kwargs): return GalleryExtension(**kwargs) CARD_LATEX = u"""\\NewDocumentEnvironment{card}{mm}{ % \\tcbset{width=#1,title=#2} \\begin{tcolorbox}[fonttitle=\\bfseries, colback=white, colframe=card-frame] }{ % \\end{tcolorbox} } """ Card = tokens.newToken('Card') CardImage = tokens.newToken('CardImage', src=u'', media_source=u'') CardTitle = tokens.newToken('CardTitle') CardContent = tokens.newToken('CardContent') Gallery = tokens.newToken('Gallery', large=3, medium=6, small=12) class GalleryExtension(media.MediaExtensionBase): """ Adds commands needed to create image galleries. """ @staticmethod def defaultConfig(): config = media.MediaExtensionBase.defaultConfig() return config
#* Licensed under LGPL 2.1, please see LICENSE for details #* https://www.gnu.org/licenses/lgpl-2.1.html import re import logging import anytree from MooseDocs.base import renderers, components from MooseDocs.tree import html, tokens from MooseDocs.extensions import core, command LOG = logging.getLogger(__name__) def make_extension(**kwargs): """Create an instance of the Extension object.""" return RevealExtension(**kwargs) Section = tokens.newToken('Section') SubSection = tokens.newToken('SubSection') Notes = tokens.newToken('Notes') class RevealExtension(command.CommandExtension): """ Presentation extension using Reveal.js """ @staticmethod def defaultConfig(): config = command.CommandExtension.defaultConfig() config['translate'] = (['index.md'], "The files that should be translated, this allows " \ "files that are included to only be translated once.") return config def initMetaData(self, page, meta):
#* https://github.com/idaholab/moose/blob/master/COPYRIGHT #* #* Licensed under LGPL 2.1, please see LICENSE for details #* https://www.gnu.org/licenses/lgpl-2.1.html import re import MooseDocs from MooseDocs.base import components from MooseDocs.extensions import command, floats from MooseDocs.tree import html, tokens def make_extension(**kwargs): return TableExtension(**kwargs) Table = tokens.newToken('Table') TableBody = tokens.newToken('TableBody') TableHead = tokens.newToken('TableHead') TableHeadItem = tokens.newToken('TableHeadItem') TableRow = tokens.newToken('TableRow') TableItem = tokens.newToken('TableItem', align='center') def builder(rows, headings=None): """Helper for creating tokens for a table.""" node = Table(None) if headings: thead = TableHead(node) row = TableRow(thead) for h in headings: th = TableHeadItem(row, align='left') tokens.String(th, content=unicode(h))
import anytree import mooseutils import MooseDocs from MooseDocs import common from MooseDocs.common import exceptions from MooseDocs.base import components, LatexRenderer, HTMLRenderer from MooseDocs.extensions import core, command, floats, autolink from MooseDocs.tree import tokens, html, latex LOG = logging.getLogger(__name__) def make_extension(**kwargs): return SQAExtension(**kwargs) SQARequirementMatrix = tokens.newToken('SQARequirementMatrix') SQARequirementMatrixItem = tokens.newToken('SQARequirementMatrixItem', label=None, reqname=None, satisfied=True) SQARequirementMatrixListItem = tokens.newToken('SQARequirementMatrixListItem', label=None) SQARequirementText = tokens.newToken('SQARequirementText') SQARequirementDesign = tokens.newToken('SQARequirementDesign', design=[], line=None, filename=None) SQARequirementIssues = tokens.newToken('SQARequirementIssues', issues=[], line=None, filename=None) SQARequirementSpecification = tokens.newToken('SQARequirementSpecification', spec_name=None, spec_path=None) SQARequirementPrequisites = tokens.newToken('SQARequirementPrequisites', specs=[]) SQARequirementDetails = tokens.newToken('SQARequirementDetails') SQARequirementDetailItem = tokens.newToken('SQARequirementDetailItem', label=None) SQARequirementMatrixHeading = tokens.newToken('SQARequirementMatrixHeading', category=None) LATEX_REQUIREMENT = """
#* #* Licensed under LGPL 2.1, please see LICENSE for details #* https://www.gnu.org/licenses/lgpl-2.1.html import collections from MooseDocs.base import components from MooseDocs.common import exceptions from MooseDocs.extensions import command, table, floats from MooseDocs.tree import tokens, html def make_extension(**kwargs): return AcronymExtension(**kwargs) AcronymItem = collections.namedtuple('AcronymItem', 'key name used') AcronymToken = tokens.newToken('AcronymToken', acronym=u'') AcronymListToken = tokens.newToken('AcronymListToken', heading=True) class AcronymExtension(command.CommandExtension): """ Adds ability to create acronyms within the configuration and use them throughout the pages. """ @staticmethod def defaultConfig(): config = command.CommandExtension.defaultConfig() config['acronyms'] = (dict(), "Complete dict (or dict of dict) of acronyms.") return config def __init__(self, *args, **kwargs): command.CommandExtension.__init__(self, *args, **kwargs)