diff --git a/README.md b/README.md index 9b7f7bc..2c47dd5 100644 --- a/README.md +++ b/README.md @@ -36,17 +36,11 @@ And thats it, the magic is done. ## Setup -Recommended of getting it up and running: +Recommended way for daily usage: ```bash -$ virtualenv --python python3.8 pulpdocs-venv -$ . pulpdocs-venv/bin/activate -$ pip install git+https://github.com/pedro-psb/pulp-docs -$ pulp-docs --help +$ pipx install git+https://github.com/pedro-psb/pulp-docs --include-deps $ pulp-docs serve ``` -Known issues: -- doesn't work with newer versions of python, like 3.12 -- doesn't work with pipx (some problem with data assets packaging) - +For development, use your prefered method! diff --git a/pyproject.toml b/pyproject.toml index 691377d..b2f3eec 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -25,4 +25,3 @@ pulp_docs = ["data/**"] [tool.setuptools.packages.find] where = ["src"] - diff --git a/src/pulp_docs/plugin_repos.py b/src/pulp_docs/plugin_repos.py index 8199dbb..b966e54 100644 --- a/src/pulp_docs/plugin_repos.py +++ b/src/pulp_docs/plugin_repos.py @@ -26,19 +26,22 @@ RESTAPI_TEMPLATE = "https://docs.pulpproject.org/{}/restapi.html" -@dataclass +# @dataclass # raising errors in py311/312 class RepoStatus: """ Usefull status information about a downloaded repository. """ - download_source: t.Optional[str] = None - use_local_checkout: bool = False - has_readme: bool = True - has_changelog: bool = True - has_staging_docs: bool = True - using_cache: bool = False - original_refs: t.Optional[str] = None # as defined in repolist.yml + def __init__(self, **kwargs): + self.download_source = kwargs.get("download_source", None) + self.download_source = kwargs.get("download_source", None) + self.use_local_checkout = kwargs.get("use_local_checkout", False) + self.has_readme = kwargs.get("has_readme", True) + self.has_changelog = kwargs.get("has_changelog", True) + self.has_staging_docs = kwargs.get("has_staging_docs", True) + self.using_cache = kwargs.get("using_cache", False) + self.original_refs = kwargs.get("original_refs", None) + @dataclass class Repo: diff --git a/tests/fixtures/pulpcore/docs/index.md b/tests/fixtures/pulpcore/staging_docs/index.md similarity index 99% rename from tests/fixtures/pulpcore/docs/index.md rename to tests/fixtures/pulpcore/staging_docs/index.md index 56dd702..7788cb5 100644 --- a/tests/fixtures/pulpcore/docs/index.md +++ b/tests/fixtures/pulpcore/staging_docs/index.md @@ -45,3 +45,4 @@ This is a landing page. [:octicons-arrow-right-24: License](#) + diff --git a/tests/fixtures/pulpcore/docs/reference/main.md b/tests/fixtures/pulpcore/staging_docs/reference/main.md similarity index 100% rename from tests/fixtures/pulpcore/docs/reference/main.md rename to tests/fixtures/pulpcore/staging_docs/reference/main.md diff --git a/tests/fixtures/pulpcore/docs/sections/development/guides/How to bind analysis trade..md b/tests/fixtures/pulpcore/staging_docs/sections/development/guides/How to bind analysis trade..md similarity index 100% rename from tests/fixtures/pulpcore/docs/sections/development/guides/How to bind analysis trade..md rename to tests/fixtures/pulpcore/staging_docs/sections/development/guides/How to bind analysis trade..md diff --git a/tests/fixtures/pulpcore/docs/sections/development/index.md b/tests/fixtures/pulpcore/staging_docs/sections/development/index.md similarity index 100% rename from tests/fixtures/pulpcore/docs/sections/development/index.md rename to tests/fixtures/pulpcore/staging_docs/sections/development/index.md diff --git a/tests/fixtures/pulpcore/docs/sections/development/onboarding/About autonomous Model deployment.md b/tests/fixtures/pulpcore/staging_docs/sections/development/onboarding/About autonomous Model deployment.md similarity index 100% rename from tests/fixtures/pulpcore/docs/sections/development/onboarding/About autonomous Model deployment.md rename to tests/fixtures/pulpcore/staging_docs/sections/development/onboarding/About autonomous Model deployment.md diff --git a/tests/fixtures/pulpcore/docs/sections/development/onboarding/On autonomous Database deployment.md b/tests/fixtures/pulpcore/staging_docs/sections/development/onboarding/On autonomous Database deployment.md similarity index 100% rename from tests/fixtures/pulpcore/docs/sections/development/onboarding/On autonomous Database deployment.md rename to tests/fixtures/pulpcore/staging_docs/sections/development/onboarding/On autonomous Database deployment.md diff --git a/tests/fixtures/pulpcore/docs/sections/development/onboarding/On scalable Database ecossystem.md b/tests/fixtures/pulpcore/staging_docs/sections/development/onboarding/On scalable Database ecossystem.md similarity index 100% rename from tests/fixtures/pulpcore/docs/sections/development/onboarding/On scalable Database ecossystem.md rename to tests/fixtures/pulpcore/staging_docs/sections/development/onboarding/On scalable Database ecossystem.md diff --git a/tests/fixtures/pulpcore/docs/sections/development/onboarding/Understanding complex Model deployment.md b/tests/fixtures/pulpcore/staging_docs/sections/development/onboarding/Understanding complex Model deployment.md similarity index 100% rename from tests/fixtures/pulpcore/docs/sections/development/onboarding/Understanding complex Model deployment.md rename to tests/fixtures/pulpcore/staging_docs/sections/development/onboarding/Understanding complex Model deployment.md diff --git a/tests/fixtures/pulpcore/docs/sections/development/quickstart/01-doc-workflow.md b/tests/fixtures/pulpcore/staging_docs/sections/development/quickstart/01-doc-workflow.md similarity index 100% rename from tests/fixtures/pulpcore/docs/sections/development/quickstart/01-doc-workflow.md rename to tests/fixtures/pulpcore/staging_docs/sections/development/quickstart/01-doc-workflow.md diff --git a/tests/fixtures/pulpcore/docs/sections/development/quickstart/02-code-workflow.md b/tests/fixtures/pulpcore/staging_docs/sections/development/quickstart/02-code-workflow.md similarity index 100% rename from tests/fixtures/pulpcore/docs/sections/development/quickstart/02-code-workflow.md rename to tests/fixtures/pulpcore/staging_docs/sections/development/quickstart/02-code-workflow.md diff --git a/tests/fixtures/pulpcore/docs/sections/development/quickstart/_03-commit-guide.md b/tests/fixtures/pulpcore/staging_docs/sections/development/quickstart/_03-commit-guide.md similarity index 100% rename from tests/fixtures/pulpcore/docs/sections/development/quickstart/_03-commit-guide.md rename to tests/fixtures/pulpcore/staging_docs/sections/development/quickstart/_03-commit-guide.md diff --git a/tests/fixtures/pulpcore/docs/sections/getting_started/fundamentals/About autonomous Model deployment.md b/tests/fixtures/pulpcore/staging_docs/sections/getting_started/fundamentals/About autonomous Model deployment.md similarity index 100% rename from tests/fixtures/pulpcore/docs/sections/getting_started/fundamentals/About autonomous Model deployment.md rename to tests/fixtures/pulpcore/staging_docs/sections/getting_started/fundamentals/About autonomous Model deployment.md diff --git a/tests/fixtures/pulpcore/docs/sections/getting_started/fundamentals/On autonomous Database deployment.md b/tests/fixtures/pulpcore/staging_docs/sections/getting_started/fundamentals/On autonomous Database deployment.md similarity index 100% rename from tests/fixtures/pulpcore/docs/sections/getting_started/fundamentals/On autonomous Database deployment.md rename to tests/fixtures/pulpcore/staging_docs/sections/getting_started/fundamentals/On autonomous Database deployment.md diff --git a/tests/fixtures/pulpcore/docs/sections/getting_started/fundamentals/On scalable Database ecossystem.md b/tests/fixtures/pulpcore/staging_docs/sections/getting_started/fundamentals/On scalable Database ecossystem.md similarity index 100% rename from tests/fixtures/pulpcore/docs/sections/getting_started/fundamentals/On scalable Database ecossystem.md rename to tests/fixtures/pulpcore/staging_docs/sections/getting_started/fundamentals/On scalable Database ecossystem.md diff --git a/tests/fixtures/pulpcore/docs/sections/getting_started/fundamentals/Understanding complex Model deployment.md b/tests/fixtures/pulpcore/staging_docs/sections/getting_started/fundamentals/Understanding complex Model deployment.md similarity index 100% rename from tests/fixtures/pulpcore/docs/sections/getting_started/fundamentals/Understanding complex Model deployment.md rename to tests/fixtures/pulpcore/staging_docs/sections/getting_started/fundamentals/Understanding complex Model deployment.md diff --git a/tests/fixtures/pulpcore/docs/sections/getting_started/index.md b/tests/fixtures/pulpcore/staging_docs/sections/getting_started/index.md similarity index 100% rename from tests/fixtures/pulpcore/docs/sections/getting_started/index.md rename to tests/fixtures/pulpcore/staging_docs/sections/getting_started/index.md diff --git a/tests/fixtures/pulpcore/docs/sections/getting_started/quickstart/01-overview.md b/tests/fixtures/pulpcore/staging_docs/sections/getting_started/quickstart/01-overview.md similarity index 100% rename from tests/fixtures/pulpcore/docs/sections/getting_started/quickstart/01-overview.md rename to tests/fixtures/pulpcore/staging_docs/sections/getting_started/quickstart/01-overview.md diff --git a/tests/fixtures/pulpcore/docs/sections/getting_started/quickstart/02-setup.md b/tests/fixtures/pulpcore/staging_docs/sections/getting_started/quickstart/02-setup.md similarity index 100% rename from tests/fixtures/pulpcore/docs/sections/getting_started/quickstart/02-setup.md rename to tests/fixtures/pulpcore/staging_docs/sections/getting_started/quickstart/02-setup.md diff --git a/tests/fixtures/pulpcore/docs/sections/getting_started/quickstart/03-installation.md b/tests/fixtures/pulpcore/staging_docs/sections/getting_started/quickstart/03-installation.md similarity index 100% rename from tests/fixtures/pulpcore/docs/sections/getting_started/quickstart/03-installation.md rename to tests/fixtures/pulpcore/staging_docs/sections/getting_started/quickstart/03-installation.md diff --git a/tests/fixtures/pulpcore/docs/sections/getting_started/quickstart/04-configuration.md b/tests/fixtures/pulpcore/staging_docs/sections/getting_started/quickstart/04-configuration.md similarity index 100% rename from tests/fixtures/pulpcore/docs/sections/getting_started/quickstart/04-configuration.md rename to tests/fixtures/pulpcore/staging_docs/sections/getting_started/quickstart/04-configuration.md diff --git a/tests/fixtures/pulpcore/docs/sections/getting_started/quickstart/05-deployment.md b/tests/fixtures/pulpcore/staging_docs/sections/getting_started/quickstart/05-deployment.md similarity index 100% rename from tests/fixtures/pulpcore/docs/sections/getting_started/quickstart/05-deployment.md rename to tests/fixtures/pulpcore/staging_docs/sections/getting_started/quickstart/05-deployment.md diff --git a/tests/fixtures/pulpcore/docs/sections/getting_started/quickstart/06-conclusion.md b/tests/fixtures/pulpcore/staging_docs/sections/getting_started/quickstart/06-conclusion.md similarity index 100% rename from tests/fixtures/pulpcore/docs/sections/getting_started/quickstart/06-conclusion.md rename to tests/fixtures/pulpcore/staging_docs/sections/getting_started/quickstart/06-conclusion.md diff --git a/tests/fixtures/pulpcore/docs/sections/guides/index.md b/tests/fixtures/pulpcore/staging_docs/sections/guides/index.md similarity index 100% rename from tests/fixtures/pulpcore/docs/sections/guides/index.md rename to tests/fixtures/pulpcore/staging_docs/sections/guides/index.md diff --git a/tests/fixtures/pulpcore/docs/sections/learn/index.md b/tests/fixtures/pulpcore/staging_docs/sections/learn/index.md similarity index 100% rename from tests/fixtures/pulpcore/docs/sections/learn/index.md rename to tests/fixtures/pulpcore/staging_docs/sections/learn/index.md diff --git a/tests/fixtures/pulpcore/docs/sections/reference/01-repository-map.md b/tests/fixtures/pulpcore/staging_docs/sections/reference/01-repository-map.md similarity index 100% rename from tests/fixtures/pulpcore/docs/sections/reference/01-repository-map.md rename to tests/fixtures/pulpcore/staging_docs/sections/reference/01-repository-map.md diff --git a/tests/fixtures/pulpcore/docs/sections/reference/02-glossary.md b/tests/fixtures/pulpcore/staging_docs/sections/reference/02-glossary.md similarity index 100% rename from tests/fixtures/pulpcore/docs/sections/reference/02-glossary.md rename to tests/fixtures/pulpcore/staging_docs/sections/reference/02-glossary.md diff --git a/tests/fixtures/pulpcore/docs/sections/reference/index.md b/tests/fixtures/pulpcore/staging_docs/sections/reference/index.md similarity index 100% rename from tests/fixtures/pulpcore/docs/sections/reference/index.md rename to tests/fixtures/pulpcore/staging_docs/sections/reference/index.md diff --git a/tests/test_cli.py b/tests/test_cli.py index b3a83fb..1b60da3 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -3,6 +3,7 @@ from pathlib import Path import pytest +import subprocess from click.testing import CliRunner from pulp_docs.main import main @@ -23,8 +24,16 @@ def test_trivial(): def test_build(tmp_path): + """Sanity check build cmd""" + # setup folder structure so test uses local fixtures + fixture_path = Path("tests/fixtures/pulpcore").absolute() + dest_path = tmp_path / "workdir" / fixture_path.name + shutil.copytree(fixture_path, dest_path) + subprocess.run(["git", "-C", str(dest_path.absolute()), "init"]) + runner = CliRunner() with runner.isolated_filesystem(temp_dir=tmp_path): + os.chdir(dest_path) # using local checkout depends on cwd result = runner.invoke(main, "build", env={"TMPDIR": str(tmp_path.absolute())}) assert result.exit_code == 0 assert Path("site").exists() diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..ad5a418 --- /dev/null +++ b/tox.ini @@ -0,0 +1,10 @@ +[tox] +requires = + tox>=4 +env_list = py{38,39,310,311,312} + +[testenv] +description = run tests +deps = pytest +commands = + pytest {posargs:tests}