Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __format_symbols(self, formatter, link_resolver):
for symbol in self.symbols:
if symbol is None:
continue
debug('Formatting symbol %s in page %s' % (
symbol.unique_name, self.name), 'formatting')
symbol.detailed_description = formatter.format_symbol(
symbol, link_resolver)
tsl = self.typed_symbols.get(type(symbol))
if tsl:
tsl.symbols.append(symbol)
by_parent_symbols = self.by_parent_symbols.get(symbol.parent_name)
if not by_parent_symbols:
by_parent_symbols = self.__get_empty_typed_symbols()
parent_name = symbol.parent_name
if parent_name is None:
parent_name = 'Others symbols'
self.by_parent_symbols[symbol.parent_name] = by_parent_symbols
by_parent_symbols.get(type(symbol)).symbols.append(symbol)
self.symbols.append(symbol)
debug('Resolved symbol %s to page %s' %
(symbol.unique_name, self.link.ref), 'resolution')
def debug(message):
core_debug(message, domain='c-extension')
def parse_toplevel_config(self, config):
"""Parse @config to setup @self state."""
if not Formatter.initialized:
html_theme = config.get('html_theme', 'default')
if html_theme != 'default':
uri = urllib.parse.urlparse(html_theme)
if not uri.scheme:
html_theme = config.get_path('html_theme')
debug("Using theme located at %s" % html_theme)
elif uri.scheme.startswith('http'):
html_theme = self.__download_theme(uri)
if html_theme == 'default':
default_theme = os.path.join(HERE, os.pardir,
'hotdoc_bootstrap_theme', 'dist')
html_theme = os.path.abspath(default_theme)
debug("Using default theme")
theme_meta_path = os.path.join(html_theme, 'theme.json')
if os.path.exists(theme_meta_path):
with open(theme_meta_path, 'r') as _:
Formatter.theme_meta = json.loads(_.read())
def __format_symbols(self, formatter, link_resolver):
for symbol in self.symbols:
if symbol is None:
continue
debug('Formatting symbol %s in page %s' % (
symbol.unique_name, self.source_file), 'formatting')
symbol.skip = not formatter.format_symbol(symbol, link_resolver)
wset = pkg_resources.WorkingSet([])
distributions, _ = wset.find_plugins(pkg_resources.Environment(paths))
for dist in distributions:
sys.path.append(dist.location)
wset.add(dist)
for entry_point in wset.iter_entry_points(group='hotdoc.extensions',
name='get_extension_classes'):
try:
activation_function = entry_point.load()
classes = activation_function()
# pylint: disable=broad-except
except Exception as exc:
info("Failed to load %s %s" % (entry_point.module_name, exc))
debug(traceback.format_exc())
continue
for klass in classes:
extra_classes.append(klass)
return extra_classes
def rename_symbol(self, unique_name, target):
sym = self.__symbols.get(target)
if sym:
for alias in self.__aliased[unique_name]:
alias.target = unique_name
if sym.unique_name == sym.display_name:
sym.display_name = unique_name
sym.unique_name = unique_name
del self.__symbols[target]
self.__symbols[unique_name] = sym
debug('Renamed symbol with unique name %s to %s' % (target, unique_name))
return sym
tsl = self.typed_symbols.get(type(symbol))
if tsl:
tsl.symbols.append(symbol)
by_parent_symbols = self.by_parent_symbols.get(symbol.parent_name)
if not by_parent_symbols:
by_parent_symbols = self.__get_empty_typed_symbols()
parent_name = symbol.parent_name
if parent_name is None:
parent_name = 'Others symbols'
self.by_parent_symbols[symbol.parent_name] = by_parent_symbols
by_parent_symbols.get(type(symbol)).symbols.append(symbol)
self.symbols.append(symbol)
debug('Resolved symbol %s to page %s' %
(symbol.display_name, self.link.ref), 'resolution')