-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c93c1a5
commit 5d6e35b
Showing
10 changed files
with
729 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
coverage: | ||
status: | ||
project: | ||
default: | ||
informational: true | ||
patch: | ||
default: | ||
informational: true | ||
changes: | ||
default: | ||
informational: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +0,0 @@ | ||
# pyright: strict, reportUnnecessaryIsInstance=false | ||
|
||
from devdocs2zim.__about__ import __version__ | ||
|
||
|
||
def compute(a: int, b: int) -> int: | ||
if not isinstance(a, int) or not isinstance(b, int): | ||
msg = "int only" | ||
raise TypeError(msg) | ||
return a + b | ||
|
||
|
||
def entrypoint(): | ||
print(f"Hello from {__version__}") # noqa: T201 | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import argparse | ||
import logging | ||
|
||
from devdocs2zim.client import DevdocsClient | ||
from devdocs2zim.constants import ( | ||
DEVDOCS_DOCUMENTS_URL, | ||
DEVDOCS_FRONTEND_URL, | ||
NAME, | ||
VERSION, | ||
logger, | ||
) | ||
from devdocs2zim.generator import DocFilter, Generator, ZimConfig | ||
|
||
|
||
def main() -> None: | ||
parser = argparse.ArgumentParser( | ||
prog=NAME, | ||
) | ||
|
||
parser.add_argument( | ||
"--debug", help="Enable verbose output", action="store_true", default=False | ||
) | ||
|
||
parser.add_argument( | ||
"--version", | ||
help="Display scraper version and exit", | ||
action="version", | ||
version=VERSION, | ||
) | ||
|
||
parser.add_argument( | ||
"--output", | ||
help="Output folder for ZIMs. Default: /output", | ||
default="/output", | ||
dest="output_folder", | ||
) | ||
|
||
# ZIM configuration flags | ||
ZimConfig.add_flags( | ||
parser, | ||
ZimConfig( | ||
name_format="devdocs_{slug_without_version}_{version}", | ||
creator="DevDocs", | ||
publisher="openZIM", | ||
title_format="{full_name} Docs", | ||
description_format="{full_name} docs by DevDocs", | ||
long_description_format=None, | ||
tags="devdocs;{slug_without_version}", | ||
), | ||
) | ||
|
||
# Document selection flags | ||
DocFilter.add_flags(parser) | ||
|
||
# Client configuration flags | ||
parser.add_argument( | ||
"--devdocs-frontend-url", | ||
help="Scheme and hostname for the devdocs frontend.", | ||
default=DEVDOCS_FRONTEND_URL, | ||
) | ||
|
||
parser.add_argument( | ||
"--devdocs-documents-url", | ||
help="Scheme and hostname for the devdocs documents server.", | ||
default=DEVDOCS_DOCUMENTS_URL, | ||
) | ||
|
||
args = parser.parse_args() | ||
|
||
logger.setLevel(level=logging.DEBUG if args.debug else logging.INFO) | ||
|
||
try: | ||
zim_config = ZimConfig.of(args) | ||
doc_filter = DocFilter.of(args) | ||
devdocs_client = DevdocsClient( | ||
documents_url=args.devdocs_documents_url, | ||
frontend_url=args.devdocs_frontend_url, | ||
) | ||
|
||
Generator( | ||
devdocs_client=devdocs_client, | ||
zim_config=zim_config, | ||
output_folder=args.output_folder, | ||
doc_filter=doc_filter, | ||
).run() | ||
except Exception as e: | ||
logger.exception(e) | ||
logger.error(f"Generation failed with the following error: {e}") | ||
raise SystemExit(1) from e | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
Oops, something went wrong.