def setUp(self): Logger.reset() Logger.silent = True Logger.register_error_code('foo', FooError, 'bar') Logger.register_warning_code('baz', BazError, 'bar')
""" import re import cgi from itertools import izip_longest from hotdoc.core.comment_block import (Comment, Annotation, Tag, comment_from_tag) from hotdoc.core.exceptions import HotdocSourceException from hotdoc.utils.configurable import Configurable from hotdoc.parsers import cmark from hotdoc.utils.loggable import Logger, warn Logger.register_warning_code('gtk-doc-bad-link', HotdocSourceException) Logger.register_warning_code('gtk-doc-bad-syntax', HotdocSourceException) # http://stackoverflow.com/questions/434287/what-is-the-most-pythonic-way-to-iterate-over-a-list-in-chunks def _grouper(iterable, n_args, fillvalue=None): """ Banana banana """ args = [iter(iterable)] * n_args return izip_longest(*args, fillvalue=fillvalue) # pylint: disable=too-few-public-methods class GtkDocParser(object): """
"""GitUploadExtension""" import os import shutil import subprocess from subprocess import check_output as call import urllib.parse import appdirs from hotdoc.utils.utils import recursive_overwrite from hotdoc.core.extension import Extension from hotdoc.core.exceptions import HotdocException from hotdoc.utils.loggable import Logger, warn Logger.register_warning_code('no-local-repository', HotdocException, domain='git-uploader') Logger.register_warning_code('dirty-local-repository', HotdocException, domain='git-uploader') Logger.register_warning_code('git-error', HotdocException, domain='git-uploader') DESCRIPTION =\ """ An extension to upload the result of a hotdoc build to git a repository. It can be used to upload to github pages for example. """
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') def get_clang_headers(): version = subprocess.check_output(['llvm-config',
from hotdoc.utils.loggable import info, Logger, error from hotdoc.utils.utils import OrderedSet from hotdoc.core.extension import Extension from hotdoc.core.symbols import ClassSymbol, QualifiedSymbol, PropertySymbol, \ SignalSymbol, ReturnItemSymbol, ParameterSymbol, Symbol from hotdoc.parsers.gtk_doc import GtkDocParser from hotdoc.extensions.c.utils import CCommentExtractor from hotdoc.core.exceptions import HotdocSourceException from hotdoc.core.formatter import Formatter from hotdoc.core.comment import Comment from hotdoc.extensions.gi.gi_extension import WritableFlag, ReadableFlag, \ ConstructFlag, ConstructOnlyFlag from hotdoc.extensions.gi.gtkdoc_links import gather_gtk_doc_links from hotdoc.extensions.devhelp.devhelp_extension import TYPE_MAP Logger.register_warning_code('signal-arguments-mismatch', HotdocSourceException, 'gst-extension') DESCRIPTION =\ """ Extract gstreamer plugin documentation from sources and built plugins. """ def _cleanup_package_name(package_name): return package_name.strip('git').strip('release').strip( 'prerelease').strip('GStreamer').strip('Plug-ins').strip(' ') def create_hierarchy(element_dict):
from hotdoc.core.symbols import * from hotdoc.core.base_extension import BaseExtension, ExtDependency from hotdoc.core.base_formatter import Formatter from hotdoc.core.file_includer import find_md_file from hotdoc.core.links import Link, LinkResolver from hotdoc.core.doc_tree import Page from hotdoc.core.comment_block import Comment from hotdoc.core.exceptions import BadInclusionException from hotdoc.utils.loggable import warn, Logger from .gi_html_formatter import GIHtmlFormatter from .gi_annotation_parser import GIAnnotationParser from .fundamentals import PY_FUNDAMENTALS, JS_FUNDAMENTALS Logger.register_warning_code('missing-gir-include', BadInclusionException, 'gi-extension') class Flag (object): def __init__ (self, nick, link): self.nick = nick self.link = link class RunLastFlag (Flag): def __init__(self): Flag.__init__ (self, "Run Last", "https://developer.gnome.org/gobject/unstable/gobject-Signals.html#G-SIGNAL-RUN-LAST:CAPS") class RunFirstFlag (Flag):
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:hotdoc="uri:hotdoc"> <xsl:variable name="subpages" select="hotdoc:subpages()" /> <xsl:template match="subpages"> <xsl:apply-templates select="$subpages" /> </xsl:template> <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> </xsl:stylesheet>''') 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') HERE = os.path.dirname(__file__) # pylint: disable=too-few-public-methods class TocSection(object): """ Banana banana
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:hotdoc="uri:hotdoc"> <xsl:variable name="subpages" select="hotdoc:subpages()" /> <xsl:template match="subpages"> <xsl:apply-templates select="$subpages" /> </xsl:template> <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> </xsl:stylesheet>''') 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):
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())
ALL_GIRS = {} ALIASED_LINKS = {l: {} for l in OUTPUT_LANGUAGES} DEFAULT_PAGE = "Miscellaneous.default_page" DEFAULT_PAGE_COMMENT = """/** * Miscellaneous.default_page: * @title: Miscellaneous * @short-description: Miscellaneous unordered symbols * * Unordered miscellaneous symbols that were not properly documented */ """ Logger.register_warning_code('no-location-indication', InvalidOutputException, 'gi-extension') class GIExtension(Extension): extension_name = "gi-extension" argument_prefix = "gi" def __init__(self, app, project): Extension.__init__(self, app, project) self.languages = None self.__all_sources = None self.__current_output_filename = None self.__class_gtype_structs = {} self.__default_page = DEFAULT_PAGE
from docutils.core import publish_parts from docutils.utils import error_reporting from docutils import nodes from hotdoc.core.comment_block import Comment from hotdoc.core.exceptions import HotdocSourceException from hotdoc.utils.loggable import Logger, warn from docutils.statemachine import ViewList from docutils.writers.html4css1 import Writer as HtmlWriter from docutils.parsers.rst import roles, directives from xml.sax.saxutils import unescape from hotdoc_python_extension.napoleon import Config from hotdoc_python_extension.napoleon import docstring Logger.register_warning_code('python-doc-issue', HotdocSourceException) _google_typed_arg_regex = re.compile(r'\s*(.+?)\s*\(\s*(.+?)\s*\)') class MyGoogleDocString(docstring.GoogleDocstring): def __init__(self, *args, **kwargs): self.param_fields = [] self.attribute_fields = [] self.return_fields = [] docstring.GoogleDocstring.__init__(self, *args, **kwargs) def _consume_field(self, parse_type=True, prefer_type=False): line = next(self._line_iter) before, colon, after = self._partition_field_on_colon(line)
# pylint: disable=import-error # pylint: disable=import-error from hotdoc.core.exceptions import HotdocException from hotdoc.core.symbols import Symbol from hotdoc.utils.signals import Signal from hotdoc.utils.loggable import debug, warn, Logger class RedefinedSymbolException(HotdocException): ''' Exception raised when a symbol is defined twice in the same run ''' pass Logger.register_warning_code('symbol-redefined', RedefinedSymbolException, 'extension') # pylint: disable=too-few-public-methods class ProxySymbol(Symbol): """A proxy type to handle aliased symbols""" __tablename__ = 'proxy_symbols' def __init__(self, **kwargs): self.target = None Symbol.__init__(self, **kwargs) # pylint: disable=too-many-instance-attributes class Database:
from hotdoc.core.formatter import Formatter from hotdoc.core.extension import Extension from hotdoc.utils.utils import recursive_overwrite from hotdoc.utils.loggable import warn, Logger 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' needs_licensing = False def __init__(self, app, project): Extension.__init__(self, app, project) self.__asset_folders = set() self.activated = False
Utilities and baseclasses for extensions """ import os from collections import OrderedDict from collections import defaultdict from hotdoc.core.inclusions import find_file from hotdoc.core.symbols import Symbol from hotdoc.core.tree import Page, OverridePage, PageResolutionResult from hotdoc.core.formatter import Formatter from hotdoc.utils.configurable import Configurable from hotdoc.core.exceptions import InvalidOutputException from hotdoc.utils.loggable import debug, info, warn, error, Logger from hotdoc.utils.utils import OrderedSet, DefaultOrderedDict Logger.register_warning_code('unavailable-symbol-listed', InvalidOutputException, 'extension') # pylint: disable=too-few-public-methods class ExtDependency: """ Represents a dependency on another extension. If not satisfied, the extension will not be instantiated. See the `Extension.get_dependencies` static method documentation for more information. Attributes: dependency_name: str, the name of the extension depended on. is_upstream: bool, if set to true hotdoc will arrange for
_no_duplicates_constructor) yaml.add_constructor(u'tag:yaml.org,2002:str', _custom_str_constructor) class DocTreeNoSuchPageException(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', DocTreeNoSuchPageException, 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(unicode, len), Optional('symbols'): Schema([And(unicode, len)]), Optional('short-description'): And(unicode, len)} resolving_symbol_signal = Signal() formatting_signal = Signal() def __init__(self, source_file, ast, meta=None, raw_contents=None): "Banana banana"
""" pass class IndexExtensionNotFoundException(HotdocSourceException): """ Raised when the extension was not found for an index placeholder """ pass Logger.register_error_code('index-extension-not-found', IndexExtensionNotFoundException, domain='doc-tree') Logger.register_error_code('page-not-found', PageNotFoundException, 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: "Banana banana" meta_schema = {Optional('title'): And(str, len), Optional('short-description'): And(str), Optional('description'): And(str), Optional('render-subpages'): bool, Optional('auto-sort'): bool, Optional('full-width'): bool, Optional('see-also'): And(str, len), Optional('extra'): Schema({str: object}), Optional('thumbnail'): And(str, len),
# # This library is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # details. # # You should have received a copy of the GNU Lesser General Public License # along with this library. If not, see <http://www.gnu.org/licenses/>. """ Banana banana """ import urllib.parse from hotdoc.utils.loggable import Logger, warn from hotdoc.core.exceptions import MissingLinkException Logger.register_warning_code('mandatory-link-not-found', MissingLinkException, domain='links') from hotdoc.utils.signals import Signal def dict_to_html_attrs(dict_): """ Banana banana """ res = ' '.join('%s="%s"' % (k, v) for k, v in dict_.items()) return res class Link: """
""" Extension to add links to edit pages on github """ import os import shutil import subprocess from hotdoc.utils.loggable import Logger, warn from hotdoc.core.exceptions import HotdocException from hotdoc.core.extension import Extension HERE = os.path.abspath(os.path.dirname(__file__)) PNAME = 'edit-on-github' Logger.register_warning_code('source-not-in-git-repo', HotdocException, domain=PNAME) class EditOnGitHubExtension(Extension): """Extension to upload generated doc to a git repository""" extension_name = PNAME argument_prefix = PNAME def __init__(self, app, project): self.__repo = None self.__repo_root = None self.__branch = None Extension.__init__(self, app, project) @staticmethod def add_arguments(parser):
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.
from lxml import etree 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 from hotdoc.utils.utils import OrderedSet 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 = ('./h1|h2|h2|h3|h4|h5|h6') TOK_REGEX = re.compile(r'[a-zA-Z_][a-zA-Z0-9_\.]*[a-zA-Z0-9_]*') def get_sections(root, selector='./div[@id]'): return root.xpath(selector) def parse_content(section, stop_words, selector='.//p'):
if ast_node.kind == clang.cindex.TypeKind.POINTER and \ ast_node.get_pointee().get_result().kind != \ clang.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')
import re from hotdoc.core.exceptions import HotdocSourceException from hotdoc.core.extension import Extension from hotdoc.core.tree import Page from hotdoc.core.project import Project from hotdoc.run_hotdoc import Application from hotdoc.core.formatter import Formatter from hotdoc.utils.loggable import Logger, warn, info import typing as T if T.TYPE_CHECKING: import argparse Logger.register_warning_code('unknown-refman-link', HotdocSourceException, 'refman-links') class RefmanLinksExtension(Extension): extension_name = 'refman-links' argument_prefix = 'refman' def __init__(self, app: Application, project: Project): self.project: Project super().__init__(app, project) self._data_file: T.Optional[Path] = None self._data: T.Dict[str, str] = {} @staticmethod def add_arguments(parser: 'argparse.ArgumentParser'): group = parser.add_argument_group(
import os from collections import defaultdict from lxml import etree import networkx as nx from hotdoc.core.symbols import QualifiedSymbol from hotdoc.core.exceptions import BadInclusionException from hotdoc.extensions.gi.utils import * from hotdoc.extensions.gi.fundamentals import FUNDAMENTALS from hotdoc.utils.loggable import warn, Logger Logger.register_warning_code('missing-gir-include', BadInclusionException, 'gi-extension') ''' Names of boilerplate GObject macros we don't want to expose ''' SMART_FILTERS = set() def __generate_smart_filters(id_prefixes, sym_prefixes, node): sym_prefix = node.attrib['{%s}symbol-prefix' % NS_MAP['c']] SMART_FILTERS.add(('%s_IS_%s' % (sym_prefixes, sym_prefix)).upper()) SMART_FILTERS.add(('%s_TYPE_%s' % (sym_prefixes, sym_prefix)).upper()) SMART_FILTERS.add(('%s_%s' % (sym_prefixes, sym_prefix)).upper()) SMART_FILTERS.add(('%s_%s_CLASS' % (sym_prefixes, sym_prefix)).upper()) SMART_FILTERS.add(('%s_IS_%s_CLASS' % (sym_prefixes, sym_prefix)).upper()) SMART_FILTERS.add(('%s_%s_GET_CLASS' % (sym_prefixes, sym_prefix)).upper()) SMART_FILTERS.add(('%s_%s_GET_IFACE' % (sym_prefixes, sym_prefix)).upper()) __HIERARCHY_GRAPH = nx.DiGraph()
# pylint: disable=missing-docstring import json 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")
from lxml import etree import lxml.html from collections import defaultdict from hotdoc.core.exceptions import InvalidOutputException from hotdoc.utils.loggable import info as core_info, warn, Logger from hotdoc.extensions.search.trie import Trie from hotdoc.utils.utils import OrderedSet 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=( './ul[@class="base_symbol_header"]' '/li' '/h3' '/span' '/code'