How to use the hotdoc.utils.loggable.Logger.register_warning_code 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 / 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 / core / formatter.py View on Github external
''')


Logger.register_warning_code('bad-local-link', FormatterBadLinkException,
                             domain='html-formatter')
Logger.register_warning_code('no-image-src', FormatterBadLinkException,
                             domain='html-formatter')
Logger.register_warning_code('bad-image-src', FormatterBadLinkException,
                             domain='html-formatter')
Logger.register_warning_code('download-theme-error', HotdocException,
                             domain='html-formatter')


HERE = os.path.dirname(__file__)


def _download_progress_cb(blocknum, blocksize, totalsize):
    """Banana Banana"""
    readsofar = blocknum * blocksize
    if totalsize > 0:
github hotdoc / hotdoc / hotdoc / extensions / c / c_extension.py View on Github external
if ast_node.kind == cindex.TypeKind.POINTER and \
            ast_node.get_pointee().get_result().kind != \
            cindex.TypeKind.INVALID:
        return True
    return False


def info(message):
    core_info(message, domain='c-extension')


def debug(message):
    core_debug(message, domain='c-extension')


Logger.register_warning_code('clang-diagnostic', ParsingException,
                             'c-extension')
Logger.register_warning_code('clang-heisenbug', ParsingException,
                             'c-extension')
Logger.register_warning_code('clang-flags', ParsingException,
                             'c-extension')
Logger.register_warning_code('bad-c-inclusion', BadInclusionException,
                             'c-extension')
Logger.register_warning_code('clang-headers-not-found', HotdocException,
                             'c-extension')


CLANG_HEADERS_WARNING = (
'Did not find clang headers. Please report a bug with the output of the'
'\'llvm-config --version\' and \'llvm-config --prefix\' commands')
github hotdoc / hotdoc / hotdoc / extensions / search / create_index.py View on Github external
import lxml.html

from hotdoc.core.exceptions import InvalidOutputException
from hotdoc.utils.loggable import info as core_info, Logger

from hotdoc.extensions.search.trie import Trie


ContextualizedURL = namedtuple('ContextualizedURL', ['url', 'context'])


def info(message):
    core_info(message, domain='search-extension')

Logger.register_warning_code('invalid-html', InvalidOutputException,
                             'search-extension')

SECTIONS_SELECTOR = (
    './div[@id]'
)

INITIAL_SELECTOR = (
    './/div[@id="main"]'
)

TITLE_SELECTOR = (
    './/*[self::h1 or self::h2 or self::h3 or '
    'self::h4 or self::h5 or self::h6]'
)

TOK_REGEX = re.compile(r'[a-zA-Z_][a-zA-Z0-9_\.]*[a-zA-Z0-9_]*')
github hotdoc / hotdoc / hotdoc / extensions / c / c_extension.py View on Github external
cindex.TypeKind.INVALID:
        return True
    return False


def info(message):
    core_info(message, domain='c-extension')


def debug(message):
    core_debug(message, domain='c-extension')


Logger.register_warning_code('clang-diagnostic', ParsingException,
                             'c-extension')
Logger.register_warning_code('clang-heisenbug', ParsingException,
                             'c-extension')
Logger.register_warning_code('clang-flags', ParsingException,
                             'c-extension')
Logger.register_warning_code('bad-c-inclusion', BadInclusionException,
                             'c-extension')
Logger.register_warning_code('clang-headers-not-found', HotdocException,
                             'c-extension')


CLANG_HEADERS_WARNING = (
'Did not find clang headers. Please report a bug with the output of the'
'\'llvm-config --version\' and \'llvm-config --prefix\' commands')


def get_clang_headers():
    version = subprocess.check_output(['llvm-config', '--version']).strip().decode()
github hotdoc / hotdoc / hotdoc / core / formatter.py View on Github external
''')


Logger.register_warning_code('bad-local-link', FormatterBadLinkException,
                             domain='html-formatter')
Logger.register_warning_code('no-image-src', FormatterBadLinkException,
                             domain='html-formatter')
Logger.register_warning_code('bad-image-src', FormatterBadLinkException,
                             domain='html-formatter')
Logger.register_warning_code('download-theme-error', HotdocException,
                             domain='html-formatter')


HERE = os.path.dirname(__file__)


def _download_progress_cb(blocknum, blocksize, totalsize):
    """Banana Banana"""
    readsofar = blocknum * blocksize
    if totalsize > 0:
        percent = readsofar * 1e2 / totalsize
        msg = "\r%5.1f%% %*d / %d" % (
            percent, len(str(totalsize)), readsofar, totalsize)
        print(msg)
        if readsofar >= totalsize:  # near the end
            print("\n")
github hotdoc / hotdoc / hotdoc / core / tree.py View on Github external
OverridePage = namedtuple('OverridePage', ['source_file', 'file'])


class TreeNoSuchPageException(HotdocSourceException):
    """
    Raised when a subpage listed in the sitemap file could not be found
    in any of the include paths.
    """
    pass


Logger.register_error_code('no-such-subpage', TreeNoSuchPageException,
                           domain='doc-tree')
Logger.register_warning_code('invalid-page-metadata', InvalidPageMetadata,
                             domain='doc-tree')
Logger.register_warning_code('markdown-bad-link', HotdocSourceException)


# pylint: disable=too-many-instance-attributes
class Page(object):
    "Banana banana"
    meta_schema = {Optional('title'): And(str, len),
                   Optional('symbols'): Schema([And(str, len)]),
                   Optional('short-description'): And(str, len),
                   Optional('render-subpages'): bool,
                   Optional('auto-sort'): bool,
                   Optional('full-width'): bool,
                   Optional('extra'): Schema({str: object})}

    # pylint: disable=too-many-arguments
    def __init__(self, source_file, ast, output_path, project_name, meta=None,
                 raw_contents=None):
github hotdoc / hotdoc / hotdoc / core / extension.py View on Github external
from hotdoc.core.formatter import Formatter
from hotdoc.utils.configurable import Configurable
from hotdoc.core.exceptions import InvalidPageMetadata, InvalidOutputException
from hotdoc.utils.loggable import debug, info, warn, error, Logger
from hotdoc.utils.utils import OrderedSet, DefaultOrderedDict


class SymbolListedTwiceException(InvalidPageMetadata):
    pass


class InvalidRelocatedSourceException(InvalidPageMetadata):
    pass


Logger.register_warning_code(
    'unavailable-symbol-listed', InvalidOutputException, 'extension')
Logger.register_warning_code(
    'output-page-conflict', InvalidOutputException, 'extension')
Logger.register_warning_code(
    'symbol-listed-twice', SymbolListedTwiceException, 'extension')
Logger.register_warning_code(
    'invalid-relocated-source', InvalidRelocatedSourceException, 'extension')


# pylint: disable=too-few-public-methods
class ExtDependency:
    """
    Represents a dependency on another extension.

    If not satisfied, the extension will not be instantiated.