How to use hotdoc - 10 common examples

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 / core / tree.py View on Github external
Banana banana
        """
        raw_contents = contents

        meta = {}
        if contents.startswith('---\n'):
            split = contents.split('\n...\n', 1)
            if len(split) == 2:
                contents = split[1]
                try:
                    blocks = yaml.load_all(split[0], Loader=yaml.FullLoader)
                    for block in blocks:
                        if block:
                            meta.update(block)
                except ConstructorError as exception:
                    warn('invalid-page-metadata',
                         '%s: Invalid metadata: \n%s' % (source_file,
                                                         str(exception)))

        output_path = os.path.dirname(os.path.relpath(
            source_file, next(iter(self.project.include_paths))))

        ast = cmark.hotdoc_to_ast(contents, self, source_file)
        return Page(source_file, False, self.project.sanitized_name, extension_name,
                    source_file=source_file, ast=ast, meta=meta, raw_contents=raw_contents,
                    output_path=output_path)
github hotdoc / hotdoc / hotdoc / core / tree.py View on Github external
Banana banana
        """
        raw_contents = contents

        meta = {}
        if contents.startswith('---\n'):
            split = contents.split('\n...\n', 1)
            if len(split) == 2:
                contents = split[1]
                try:
                    blocks = yaml.load_all(split[0])
                    for block in blocks:
                        if block:
                            meta.update(block)
                except ConstructorError as exception:
                    warn('invalid-page-metadata',
                         '%s: Invalid metadata: \n%s' % (source_file,
                                                         str(exception)))

        output_path = os.path.dirname(os.path.relpath(
            source_file, next(iter(self.project.include_paths))))

        ast = cmark.hotdoc_to_ast(contents, self)
        return Page(source_file, ast, output_path, self.project.sanitized_name,
                    meta=meta, raw_contents=raw_contents)
github hotdoc / hotdoc / hotdoc / formatters / html_formatter.py View on Github external
from hotdoc.utils.setup_utils import THEME_VERSION
from hotdoc.utils.utils import OrderedSet
from hotdoc.utils.utils import id_from_text
from hotdoc.core.exceptions import HotdocException
from hotdoc.utils.loggable import Logger, warn, info


class HtmlFormatterBadLinkException(HotdocException):
    """
    Raised when a produced html page contains an empty local link
    to nowhere.
    """
    pass


Logger.register_warning_code('bad-local-link', HtmlFormatterBadLinkException,
                             domain='html-formatter')


HERE = os.path.dirname(__file__)


# pylint: disable=too-few-public-methods
class TocSection(object):
    """
    Banana banana
    """

    def __init__(self, summaries, name):
        self.summaries = summaries
        self.name = name
        self.id_ = ''.join(name.split())
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 / gi / gi_extension.py View on Github external
def __create_alias_symbol(self, node, gi_name, parent_name):
        name = get_symbol_names(node)[0]

        type_desc = type_description_from_node(node)
        aliased_type = QualifiedSymbol(type_tokens=type_desc.type_tokens)
        self.add_attrs(aliased_type, type_desc=type_desc)
        filename = self.__get_symbol_filename(name, node)

        alias_link = [l for l in type_desc.type_tokens if isinstance(l, Link)]
        for lang in self.languages:
            fund_type = lang.get_fundamental(type_desc.c_name)
            if fund_type:
                # The alias name is now considered as a FUNDAMENTAL type.
                lang.add_fundamental (name, fund_type)
            else:
                if alias_link:
                    lang.add_alias_link (name, alias_link[0])

        return self.create_symbol(AliasSymbol, node,
                                         aliased_type=aliased_type,
                                         display_name=name,
                                         filename=filename,
                                         parent_name=parent_name)
github hotdoc / hotdoc / hotdoc / extensions / gi_html_formatter.py View on Github external
Link('https://docs.python.org/2.7/library/functions.html#bool',
                        'bool', None)
        true_link = \
                Link('https://docs.python.org/2/library/constants.html#True',
                    'True', None)
        false_link = \
               Link('https://docs.python.org/2/library/constants.html#False',
                    'False', None)
        pointer_link = \
                Link('https://docs.python.org/2.7/library/functions.html#object',
                    'object', None)
        integer_link = \
                Link('https://docs.python.org/2/library/functions.html#int',
                        'int', None)
        float_link = \
                Link('https://docs.python.org/2/library/functions.html#float',
                        'float', None)
        none_link = \
                Link('https://docs.python.org/2/library/constants.html#None',
                        'None', None)
        unicode_link = \
                Link('https://docs.python.org/2/library/functions.html#unicode',
                        'unicode', None)

        gtype_link = \
                Link('https://developer.gnome.org/gobject/stable/'
                        'gobject-Type-Information.html#GType',
                        'GObject.Type', None)

        gvariant_link = \
                Link('https://developer.gnome.org/glib/stable/glib-GVariant.html',
                        'GLib.Variant', None)
github hotdoc / hotdoc / hotdoc / extensions / gi / languages / python.py View on Github external
Link('https://docs.python.org/3/library/constants.html#False',
                    'False', None)
        pointer_link = \
                Link('https://docs.python.org/3/library/functions.html#object',
                    'object', None)
        integer_link = \
                Link('https://docs.python.org/3/library/functions.html#int',
                        'int', None)
        float_link = \
                Link('https://docs.python.org/3/library/functions.html#float',
                        'float', None)
        none_link = \
                Link('https://docs.python.org/3/library/constants.html#None',
                        'None', None)
        list_link = \
                Link('https://docs.python.org/3/library/functions.html#func-list',
                     'list', None)
        gtype_link = \
                Link('https://developer.gnome.org/gobject/stable/'
                        'gobject-Type-Information.html#GType',
                        'GObject.Type', None)

        gvariant_link = \
                Link('https://developer.gnome.org/glib/stable/glib-GVariant.html',
                        'GLib.Variant', None)

        FUNDAMENTALS[cls.language_name] = {
                "none": none_link,
                "gpointer": pointer_link,
                "gconstpointer": pointer_link,
                "gboolean": boolean_link,
                "gint8": integer_link,
github hotdoc / hotdoc / hotdoc / extensions / c / c_extension.py View on Github external
def make_c_style_type_name (self, type_):
        tokens = []
        while (type_.kind == cindex.TypeKind.POINTER):
            self.__apply_qualifiers(type_, tokens)
            tokens.append ('*')
            type_ = type_.get_pointee()

        if type_.kind == cindex.TypeKind.TYPEDEF:
            d = type_.get_declaration ()
            link = Link (None, d.displayname, d.displayname)

            tokens.append (link)
            self.__apply_qualifiers(type_, tokens)
        elif type_.kind in (cindex.TypeKind.UNEXPOSED, cindex.TypeKind.ELABORATED):
            d = type_.get_declaration()
            if d.spelling:
                tokens.append(Link(None, d.displayname, d.displayname))
            else:
                tokens.append('__UNKNOWN__')
            if d.kind == cindex.CursorKind.STRUCT_DECL:
                tokens.append ('struct ')
            elif d.kind == cindex.CursorKind.ENUM_DECL:
                tokens.append ('enum ')
        else:
            tokens.append (type_.spelling + ' ')
github hotdoc / hotdoc / hotdoc / extensions / c / c_extension.py View on Github external
tokens = []
        while (type_.kind == cindex.TypeKind.POINTER):
            self.__apply_qualifiers(type_, tokens)
            tokens.append ('*')
            type_ = type_.get_pointee()

        if type_.kind == cindex.TypeKind.TYPEDEF:
            d = type_.get_declaration ()
            link = Link (None, d.displayname, d.displayname)

            tokens.append (link)
            self.__apply_qualifiers(type_, tokens)
        elif type_.kind in (cindex.TypeKind.UNEXPOSED, cindex.TypeKind.ELABORATED):
            d = type_.get_declaration()
            if d.spelling:
                tokens.append(Link(None, d.displayname, d.displayname))
            else:
                tokens.append('__UNKNOWN__')
            if d.kind == cindex.CursorKind.STRUCT_DECL:
                tokens.append ('struct ')
            elif d.kind == cindex.CursorKind.ENUM_DECL:
                tokens.append ('enum ')
        else:
            tokens.append (type_.spelling + ' ')

        tokens.reverse()
        return tokens
github hotdoc / hotdoc / hotdoc / extensions / gi / gi_extension.py View on Github external
for idx in destroy_indices:
            param = parameters[idx]
            self.add_attrs(param, is_destroy=True)

        for idx in closure_indices:
            param = parameters[idx]
            self.add_attrs(param, is_closure=True)

        # We add our instance parameter last in order not to mess with
        # the destroy indices
        if instance_param is not None:
            param, direction = self.__create_parameter_symbol(instance_param)
            parameters.insert(0, param)

        if node.attrib.get('throws') == '1':
            type_desc = SymbolTypeDesc([Link(None, 'GError', 'GError'), '*', '*'], 'GLib.Error', 'GError**', 0)
            param = ParameterSymbol(argname='error', type_tokens=type_desc.type_tokens)
            parameters.append(param)
            self.add_attrs(param, type_desc=type_desc, direction='out')

        retval = node.find(
            '{http://www.gtk.org/introspection/core/1.0}return-value')
        retval = self.__create_return_value_symbol(retval, out_parameters)

        return (parameters, retval)