def autodiscover(filename='rstview_configs'): """ Automatic discovering for available configurations Before looking at configurations files, registry start from ``settings.RSTVIEW_PARSER_FILTER_SETTINGS`` items if setted, else an empty Dict. Then it try to load possible root configurations file defined in ``settings.RSTVIEW_PARSER_ROOT_CONFIGS`` (as a Python path). And finally load each configurations files finded in ``settings.INSTALLED_APPS``. Example: .. sourcecode:: python :linenos: from rstview.discover import autodiscover autodiscover() This is something you want to be executed early in your project, usually the ``urls.py`` of your project is the best choice. Keyword Arguments: filename (string): Module filename to search for. Default to ``rstview_configs``, so it will search for a ``rstview_configs.py`` file at root of every enabled module from ``settings.INSTALLED_APPS``. Returns: list: List of successfully loaded Python paths. """ paths = [] # Directly fill registry from initial configurations setting rstview_registry.update(getattr(settings, 'RSTVIEW_PARSER_FILTER_SETTINGS', {})) # Fill path to discover from project level if any root_configurations = getattr(settings, 'RSTVIEW_PARSER_ROOT_CONFIGS', None) if root_configurations: paths.append(discover(root_configurations)) # Fill paths to discover from installed apps apps = list(settings.INSTALLED_APPS) paths = paths + [discover(app, filename=filename) for app in apps] return filter(None, paths)
from rstview.registry import rstview_registry from django.utils.translation import ugettext_lazy rstview_registry.update({ 'full_page': { 'initial_header_level': 1, 'file_insertion_enabled': False, 'raw_enabled': True, 'language_code': "fr", 'footnote_references': 'superscript', 'doctitle_xform': False, }, })
""" This file contain a syntax error for some test purpose. Don't correct it. """ from rstview.registry import rstview_registry from django.utils.translation import ugettext_lazy rstview_registry.update({
from rstview.registry import rstview_registry from django.utils.translation import ugettext_lazy rstview_registry.update({ 'bar': { 'initial_header_level': 2, 'language_code': "fr", }, })