How to use the hotdoc.core.extension.Extension function in hotdoc

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

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

github hotdoc / hotdoc / hotdoc / extensions / c / c_extension.py View on Github external
for package in config.get('pkg_config_packages') or []:
        flags.extend(pkgconfig.cflags(package).split(' '))

    extra_flags = config.get('extra_c_flags') or []
    for flag in extra_flags:
        flags.extend([f for f in flag.split()])

    return flags

DESCRIPTION =\
"""
Parse C source files to extract comments and symbols.
"""


class CExtension(Extension):
    extension_name = 'c-extension'
    argument_prefix = 'c'
    connected = False

    def __init__(self, app, project):
        Extension.__init__(self, app, project)
        self.project = project
        self.flags = []
        if not CExtension.connected:
            inclusions.include_signal.connect(self.__include_file_cb)
            CExtension.connected = True
        self.scanner = ClangScanner(self.app, self.project, self)

    def __include_file_cb(self, include_path, line_ranges, symbol_name):
        if not include_path.endswith(".c") or not symbol_name:
            return None
github hotdoc / hotdoc / hotdoc / extensions / syntax_highlighting / syntax_extension.py View on Github external
from hotdoc.core.exceptions import ConfigError

DESCRIPTION = """
This extension uses prism to syntax highlight code
snippets.
"""


HERE = os.path.dirname(__file__)


Logger.register_warning_code('syntax-invalid-theme', ConfigError,
                             'syntax-extension')


class SyntaxHighlightingExtension(Extension):
    """
    The actual syntax highlighting implementation
    """
    extension_name = 'syntax-highlighting-extension'
    argument_prefix = 'syntax-highlighting'

    def __init__(self, app, project):
        Extension.__init__(self, app, project)
        self.__asset_folders = set()
        self.activated = False

    def __formatting_page_cb(self, formatter, page):
        prism_theme = Formatter.theme_meta.get('prism-theme', 'prism')
        prism_theme_path = '%s.css' % os.path.join(HERE, 'prism', 'themes', prism_theme)

        if os.path.exists(prism_theme_path):
github hotdoc / hotdoc / hotdoc / extensions / check_since_markers / check_since_markers.py View on Github external
from hotdoc.core.exceptions import HotdocSourceException
from hotdoc.utils.loggable import Logger, warn
from hotdoc.core.extension import Extension

DESCRIPTION =\
    """
This extension allows to warn about missing `Since` markers in newly added
API.
"""


Logger.register_warning_code('missing-since-marker', HotdocSourceException,
                             'check-missing-since-markers')


class CheckMissingSinceMarkersExtension(Extension):
    extension_name = 'check-missing-since-markers'

    def __init__(self, app, project):
        Extension.__init__(self, app, project)
        self.__symbols_database = None

    @staticmethod
    def add_arguments(parser):
        group = parser.add_argument_group('since-markers-check-extension',
                                          DESCRIPTION)
        group.add_argument("--previous-symbol-index")

    def parse_toplevel_config(self, config):
        self.__symbols_database = config.get_index(prefix="previous_symbol")

    def setup(self):
github hotdoc / hotdoc / hotdoc / extensions / devhelp / devhelp_extension.py View on Github external
PropertySymbol: 'property',
    SignalSymbol: 'signal',
    ConstantSymbol: 'macro',
    FunctionMacroSymbol: 'macro',
    CallbackSymbol: 'function',
    InterfaceSymbol: 'interface',
    AliasSymbol: 'alias',
    VFunctionSymbol: 'vfunc',
    ExportedVariableSymbol: 'extern',
    FieldSymbol: 'field',
    MethodSymbol: 'function',
    ConstructorSymbol: 'function',
}


class DevhelpExtension(Extension):
    extension_name = 'devhelp-extension'
    argument_prefix = 'devhelp'

    activated = False
    __connected = False
    __resolved_symbols_map = {}

    def __init__(self, app, project):
        Extension.__init__(self, app, project)
        self.__ext_languages = defaultdict(set)
        self.__online = None

    def __writing_page_cb(self, formatter, page, path, lxml_tree):
        html_path = os.path.join(self.app.output, 'html')
        relpath = os.path.relpath(path, html_path)
github hotdoc / hotdoc / hotdoc / extensions / search / search_extension.py View on Github external
def __init__(self, app, project):
        Extension.__init__(self, app, project)
        self.__all_paths = []
        self.script = os.path.abspath(os.path.join(HERE, 'trie.js'))
github hotdoc / hotdoc / hotdoc / core / project.py View on Github external
from hotdoc.utils.loggable import info, error
from hotdoc.utils.configurable import Configurable
from hotdoc.utils.utils import OrderedSet
from hotdoc.utils.signals import Signal
from hotdoc.parsers.sitemap import SitemapParser


LANG_MAPPING = {
    'js': 'javascript',
    'xml': 'markup',
    'html': 'markup',
    'py': 'python'
}


class CoreExtension(Extension):
    """
    Banana banana
    """
    extension_name = 'core'

    def format_page(self, page, link_resolver, output):
        proj = self.project.subprojects.get(page.name)
        if proj:
            proj.format(link_resolver, output)
            page.title = proj.tree.root.title
        else:
            super(CoreExtension, self).format_page(
                page, link_resolver, output)

    def write_out_page(self, output, page):
        proj = self.project.subprojects.get(page.name)