Skip to content

Commit

Permalink
Conditionally render dev docs (#247)
Browse files Browse the repository at this point in the history
* Conditionally render dev docs

* hm

* python3

* use substitution instead

* ignore

* Exclude in code style

* other approach

* ugh

* hm

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* license

* ugh

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
flying-sheep and pre-commit-ci[bot] authored Nov 28, 2023
1 parent e5dbeef commit b477da6
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 25 deletions.
4 changes: 3 additions & 1 deletion .github/assets/cookiecutter-scverse-instance.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
"_copy_without_render": [
".github/workflows/**.yaml",
"docs/_templates/autosummary/**.rst"
]
],
"_render_devdocs": true,
"_jinja2_env_vars": { "lstrip_blocks": true, "trim_blocks": true }
}
}
4 changes: 3 additions & 1 deletion cookiecutter.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,7 @@
"_copy_without_render": [
".github/workflows/**.yaml",
"docs/_templates/autosummary/**.rst"
]
],
"_render_devdocs": false,
"_jinja2_env_vars": { "lstrip_blocks": true, "trim_blocks": true }
}
18 changes: 12 additions & 6 deletions hooks/post_gen_project.sh → hooks/post_gen_project.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
#!/bin/sh
#!/bin/env python3
from subprocess import run
from pathlib import Path

# Post processing
{% if not cookiecutter._render_devdocs %}
Path("docs/template_usage.md").unlink()
{% endif %}

# Update pre commit hooks
pre-commit autoupdate -c .pre-commit-config.yaml
pre-commit install
run("pre-commit autoupdate -c .pre-commit-config.yaml".split(), check=True)
run("pre-commit install".split(), check=True)

# The following output was generated using rich
# The formatted output is included here directly, because I don't want
# rich as another dependency for initalizing the repo.
# See .make_rich_output.py for more details.

cat << EOF
print("""
Expand Down Expand Up @@ -58,4 +64,4 @@
 • ]8;id=20647;https://cookiecutter-scverse-instance.readthedocs.io/en/latest/developer_docs.html#writing-documentation\provide documentation]8;;\, including tutorials where applicable
 • support users through github and the ]8;id=496112;https://discourse.scverse.org/\scverse discourse]8;;\
EOF
""")
4 changes: 4 additions & 0 deletions hooks/pre_gen_project.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/env python3
from subprocess import run

run("git init --initial-branch=main .".split(), check=True)
2 changes: 0 additions & 2 deletions hooks/pre_gen_project.sh

This file was deleted.

19 changes: 7 additions & 12 deletions {{cookiecutter.project_name}}/LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% if cookiecutter.license == 'MIT License' -%}
{% if cookiecutter.license == 'MIT License' %}
MIT License

Copyright (c) {% now 'local', '%Y' %}, {{ cookiecutter.author_full_name }}
Expand All @@ -20,8 +20,7 @@ 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.

{%- elif cookiecutter.license == 'BSD 2-Clause License' -%}
{% elif cookiecutter.license == 'BSD 2-Clause License' %}
BSD 2-Clause License

Copyright (c) {% now 'local', '%Y' %}, {{ cookiecutter.author_full_name }}
Expand All @@ -47,8 +46,7 @@ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

{%- elif cookiecutter.license == 'BSD 3-Clause License' -%}
{% elif cookiecutter.license == 'BSD 3-Clause License' %}
BSD 3-Clause License

Copyright (c) {% now 'local', '%Y' %}, {{ cookiecutter.author_full_name }}
Expand Down Expand Up @@ -78,8 +76,7 @@ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

{%- elif cookiecutter.license == 'Apache License Version 2.0' -%}
{% elif cookiecutter.license == 'Apache License Version 2.0' %}
Apache License Version 2.0
Version 2.0, January 2004
http://www.apache.org/licenses/
Expand Down Expand Up @@ -282,7 +279,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

{%- elif cookiecutter.license == 'GNU General Public License Version 3' -%}
{% elif cookiecutter.license == 'GNU General Public License Version 3' %}

GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Expand Down Expand Up @@ -958,8 +955,7 @@ may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>.

{%- elif cookiecutter.license == 'Unlicense' -%}
{% elif cookiecutter.license == 'Unlicense' %}
Unlicense

This is free and unencumbered software released into the public domain.
Expand All @@ -986,5 +982,4 @@ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

For more information, please refer to <https://unlicense.org>

{%- endif %}
{% endif %}
8 changes: 5 additions & 3 deletions {{cookiecutter.project_name}}/docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ pip install -e ".[dev,test,doc]"

## Code-style

This package uses [pre-commit][] to enforce consistent code-styles. On every commit, pre-commit checks will either
automatically fix issues with the code, or raise an error message. See [pre-commit checks](template_usage.md#pre-commit-checks) for
a full list of checks enabled for this repository.
This package uses [pre-commit][] to enforce consistent code-styles.
On every commit, pre-commit checks will either automatically fix issues with the code, or raise an error message.
{% if cookiecutter._render_devdocs %}
See [pre-commit checks](template_usage.md#pre-commit-checks) for a full list of checks enabled for this repository.
{% endif %}

To enable pre-commit locally, simply run

Expand Down
2 changes: 2 additions & 0 deletions {{cookiecutter.project_name}}/docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
api.md
changelog.md
{% if cookiecutter._render_devdocs %}
template_usage.md
{% endif %}
contributing.md
references.md
Expand Down

0 comments on commit b477da6

Please sign in to comment.