PK!$mudkip/__init__.py__version__ = "0.1.1" PK!h;;mudkip/__main__.pyfrom mudkip.cli import mudkip mudkip(prog_name="mudkip") PK!KLmudkip/application.pyimport sys from sphinx.application import Sphinx from sphinx.errors import SphinxError from .config import Config from .errors import MudkipError class Mudkip: def __init__(self, config=None): if config is None: config = Config() self.config = config self.sphinx = self.create_sphinx_application() def create_sphinx_application(self): extra_args = {} if not self.config.verbose: extra_args["status"] = None return Sphinx( self.config.sphinx_srcdir, self.config.sphinx_confdir, self.config.sphinx_outdir, self.config.sphinx_doctreedir, self.config.sphinx_buildername, self.config.sphinx_confoverrides, **extra_args, ) @property def watch_patterns(self): patterns = [f"**/*{suff}" for suff in self.sphinx.config.source_suffix] ignore_patterns = self.sphinx.config.exclude_patterns return patterns, ignore_patterns def build(self): try: self.sphinx.build() except SphinxError as exc: raise MudkipError(exc.args[0]) from exc PK! ( mudkip/cli.pyimport sys import time from functools import wraps from contextlib import contextmanager from traceback import format_exc import click from . import __version__ from .application import Mudkip from .config import Config from .errors import MudkipError from .watch import watch_directory def print_version(ctx, _param, value): if not value or ctx.resilient_parsing: return click.secho(f"Mudkip v{__version__}", fg="blue") ctx.exit() @click.group() @click.option( "--version", is_flag=True, is_eager=True, expose_value=False, callback=print_version, help="Show the version and exit.", ) def mudkip(): """A friendly Sphinx wrapper.""" @contextmanager def exception_handler(exit=False): try: yield except Exception as exc: error = exc.args[0] if isinstance(exc, MudkipError) else format_exc() click.secho(error, fg="red", bold=True) if exit: sys.exit(1) def config_params(command): @click.option( "--source-dir", type=click.Path(file_okay=False), help="The source directory.", default=Config.default_source_dir, ) @click.option( "--output-dir", type=click.Path(file_okay=False), help="The output directory.", default=Config.default_output_dir, ) @click.option("--verbose", is_flag=True, help="Show Sphinx output.") @wraps(command) def wrapper(*args, **kwargs): return command(*args, **kwargs) return wrapper @mudkip.add_command @click.command() @config_params def build(source_dir, output_dir, verbose): """Build documentation.""" padding = "\n" * verbose click.secho(f'Building "{source_dir}"...{padding}', fg="blue") application = Mudkip(Config(source_dir, output_dir, verbose)) with exception_handler(exit=True): application.build() click.secho("\nDone.", fg="yellow") @mudkip.add_command @click.command() @config_params def develop(source_dir, output_dir, verbose): """Start development server.""" padding = "\n" * verbose click.secho(f'Watching "{source_dir}"...{padding}', fg="blue") application = Mudkip(Config(source_dir, output_dir, verbose)) with exception_handler(): application.build() try: for event in watch_directory(source_dir, *application.watch_patterns): now = time.strftime("%H:%M:%S") click.secho(f"{padding}{now}", fg="black", bold=True, nl=False) click.echo(f" {event.src_path} {event.event_type} {padding}") with exception_handler(): application.build() except KeyboardInterrupt: click.secho("\nExit.", fg="yellow") PK!13WXXmudkip/config.pyfrom pathlib import Path class Config: default_source_dir = "docs" default_output_dir = "docs/_build" def __init__(self, source_dir=None, output_dir=None, verbose=False): self.mkdir = [] self.source_dir = Path(source_dir or self.default_source_dir) self.output_dir = Path(output_dir or self.default_output_dir) self.verbose = verbose self.mkdir += self.source_dir, self.output_dir self.configure_sphinx() for directory in self.mkdir: directory.mkdir(parents=True, exist_ok=True) def configure_sphinx(self): self.sphinx_srcdir = self.source_dir self.sphinx_outdir = self.output_dir / "sphinx" self.sphinx_doctreedir = self.sphinx_outdir / ".doctrees" self.sphinx_buildername = "xml" self.sphinx_confdir = None self.sphinx_confoverrides = { "extensions": ["recommonmark"], "master_doc": "index", "source_suffix": {".rst": "restructuredtext", ".md": "markdown"}, "exclude_patterns": [".*", "**/.*", "_*", "**/_*"], } PK!ۅ''mudkip/errors.pyclass MudkipError(Exception): pass PK!rnnmudkip/watch.pyfrom queue import Queue from watchdog.observers import Observer from watchdog.events import PatternMatchingEventHandler class QueueHandler(PatternMatchingEventHandler): def __init__(self, queue, *args, **kwargs): super().__init__(*args, **kwargs) self.queue = queue def on_any_event(self, event): self.queue.put(event) def watch_directory( path, patterns=None, ignore_patterns=None, ignore_directories=False, case_sensitive=False, recursive=True, ): queue = Queue() observer = Observer() observer.schedule( QueueHandler( queue, patterns, ignore_patterns, ignore_directories, case_sensitive ), path, recursive, ) observer.start() try: while True: yield queue.get() finally: observer.stop() observer.join() PK!HJZ|%,'mudkip-0.1.1.dist-info/entry_points.txtN+I/N.,()-M,Pz9V&PK!11mudkip-0.1.1.dist-info/LICENSEMIT License Copyright (c) 2019 Valentin Berlier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. PK!HڽTUmudkip-0.1.1.dist-info/WHEEL A н#Z;/"d&F[xzw@Zpy3Fv]\fi4WZ^EgM_-]#0(q7PK!Hli7mudkip-0.1.1.dist-info/METADATAr0z˰i3촥)4Chd&LRBU[A90lNa9 hF.\IxS*$xkJj6ɬl` .oac̠wJH{iK8箨pD\_1SrfS&gs4\ Z2鸄-"&(/ t~Vk Ѳ#Z˯@ &ZU,l;QBpÜʼM O OuҒ77>?:c0ߧP_`_4O?:xP[׭ K]q5'0Ui%8{Lw+NY):dEgJ:7/c.gj#z w߾âryoEmYYU ;D۹to -fw?F{qOo ¬p!PK!HO6|mudkip-0.1.1.dist-info/RECORDuɒ@{ ؀ pKn…@)@XV"@ENEp?1V9 p5)wuS7jL<i{ 0_'taAwNBU qY.'nf '\'w] öy-c/k>̜Mw{o9Hni%5|S(ZvSƍ)2=eyOFpiB0<|)m)  P;g"O\&Oӆ:Ӛj0JuKB-ߠ>h b,)J5#kR#y$*>|boNkfXmI5%EF0ȭ/cHjA&=&aY=Z~gM \| !(T:e+pĪO~.x֥f7'qlN9#viNLJ^VAS{\c(&6xB 5н+B>:$U*lU6ee+mG C.W8@1 PK!$mudkip/__init__.pyPK!h;;Fmudkip/__main__.pyPK!KLmudkip/application.pyPK! ( mudkip/cli.pyPK!13WXXCmudkip/config.pyPK!ۅ''mudkip/errors.pyPK!rnnmudkip/watch.pyPK!HJZ|%,'mudkip-0.1.1.dist-info/entry_points.txtPK!11#mudkip-0.1.1.dist-info/LICENSEPK!HڽTUmudkip-0.1.1.dist-info/WHEELPK!Hli7mudkip-0.1.1.dist-info/METADATAPK!HO6|0 mudkip-0.1.1.dist-info/RECORDPK :"