Skip to content

Commit

Permalink
add tests that docs folder looks correct
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisjkuch committed Nov 4, 2022
1 parent 3bc993b commit bbb271c
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 24 deletions.
43 changes: 35 additions & 8 deletions ccds.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,27 @@
"description": "A short description of the project.",
"python_version_number": "3.10",
"dataset_storage": [
{"none": "none"},
{"azure": {"container": "container-name"}},
{"s3": {"bucket": "bucket-name", "aws_profile": "default"}},
{"gcs": {"bucket": "bucket-name"}}
{
"none": "none"
},
{
"azure": {
"container": "container-name"
}
},
{
"s3": {
"bucket": "bucket-name",
"aws_profile": "default"
}
},
{
"gcs": {
"bucket": "bucket-name"
}
}
],
"environment_manager" : [
"environment_manager": [
"virtualenv",
"conda",
"pipenv",
Expand All @@ -26,6 +41,18 @@
"none",
"basic"
],
"open_source_license": ["No license file", "MIT", "BSD-3-Clause"],
"include_code_scaffold": ["Yes", "No"]
}
"open_source_license": [
"No license file",
"MIT",
"BSD-3-Clause"
],
"include_code_scaffold": [
"Yes",
"No"
],
"docs": [
"sphinx",
"mkdocs",
"none"
]
}
20 changes: 10 additions & 10 deletions hooks/post_gen_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,18 @@
"python-dotenv",
]

docs_path = Path("{{ cookiecutter.project_name }} ") / "docs"
# {% if cookiecutter.docs == "sphinx" %}
packages += ["sphinx"]
shutil.rmtree(docs_path / "mkdocs")
shutil.move(docs_path / "sphinx", docs_path)
# {% elif cookiecutter.docs == "mkdocs" %}
packages += ["mkdocs"]
pip_only_packages += ["mkdocs"]
# {% else %}
# Use the selected documentation package specified in the config,
# or none if none selected
docs_path = Path("docs")
# {% if cookiecutter.docs != "none" %}
packages += ["{{ cookiecutter.docs }}"]
pip_only_packages += ["{{ cookiecutter.docs }}"]
docs_subpath = docs_path / "{{ cookiecutter.docs }}"
for obj in docs_subpath.iterdir():
shutil.move(obj, docs_path)
# {% endif %}
shutil.rmtree(docs_path / "mkdocs")
shutil.rmtree(docs_path / "sphinx")
# {% endif %}

#
# POST-GENERATION FUNCTIONS
Expand Down
1 change: 1 addition & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def config_generator(fast=False):
("include_code_scaffold", opt)
for opt in cookiecutter_json["include_code_scaffold"]
],
[("docs", opt) for opt in cookiecutter_json["docs"]],
)

def _is_valid(config):
Expand Down
27 changes: 21 additions & 6 deletions tests/test_creation.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ def verify_folders(root, config):
f"{config['module_name']}/visualization",
]

if config["docs"] == "mkdocs":
expected_dirs += ["docs/docs"]

expected_dirs = [
# (root / d).resolve().relative_to(root) for d in expected_dirs
Path(d)
Expand Down Expand Up @@ -83,12 +86,7 @@ def verify_files(root, config):
"data/interim/.gitkeep",
"data/processed/.gitkeep",
"data/raw/.gitkeep",
"docs/Makefile",
"docs/commands.rst",
"docs/conf.py",
"docs/getting-started.rst",
"docs/index.rst",
"docs/make.bat",
"docs/.gitkeep",
"notebooks/.gitkeep",
"references/.gitkeep",
"reports/.gitkeep",
Expand All @@ -114,6 +112,23 @@ def verify_files(root, config):
f"{config['module_name']}/visualization/visualize.py",
]

if config["docs"] == "sphinx":
expected_files += [
"docs/Makefile",
"docs/commands.rst",
"docs/conf.py",
"docs/getting-started.rst",
"docs/index.rst",
"docs/make.bat",
]
elif config["docs"] == "mkdocs":
expected_files += [
"docs/mkdocs.yml",
"docs/README.md",
"docs/docs/index.md",
"docs/docs/getting-started.md",
]

expected_files.append(config["dependency_file"])

expected_files = [Path(f) for f in expected_files]
Expand Down

0 comments on commit bbb271c

Please sign in to comment.