Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

user-guide: examples #666

Merged
merged 1 commit into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ src/plugins/main-loop/built-in
src/plugins/install/built-in
src/user-guide/task-implementation/job-runner-handlers
src/dictionaries/sentence_case
src/user-guide/examples/*
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ cleanall:
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
# NOTE: EXPORT_ALL_VARIABLES exports make vars as env vars
%: Makefile .EXPORT_ALL_VARIABLES
bin/link-examples
# build documentation
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
# write out dict of available versions and formats
Expand Down
14 changes: 14 additions & 0 deletions bin/link-examples
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash

set -eu

# rm cylc-flow-examples || true
examples="$(python -c 'import cylc.flow; from pathlib import Path; print(Path(cylc.flow.__file__).parent)')/etc/examples"
for example in $(echo "${examples}/"*); do
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be a bit less awkward if this whole file was a python script?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I generally use Bash for simple systemy things like this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want to switch to the light side 😛

#!/usr/bin/env python3
from pathlib import Path
import cylc.flow

examples_dir = Path(cylc.flow.__file__).parent / "etc/examples"

for example in examples_dir.iterdir():
    if example.is_dir():
        target = Path("src/user-guide/examples") / example.name
        target.unlink(missing_ok=True)
        target.symlink_to(example)

if [[ -d "${example}" ]]; then
target="src/user-guide/examples/$(basename "${example}")"
rm "${target}" || true
ln -s "${example}" "${target}"
fi
done

9 changes: 9 additions & 0 deletions src/user-guide/examples/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Examples
========

These examples cover some of the main patterns for implementing Cylc workflows.

.. toctree::
:glob:
MetRonnie marked this conversation as resolved.
Show resolved Hide resolved

*/index
1 change: 1 addition & 0 deletions src/user-guide/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ User Guide
:maxdepth: 2

introduction
examples/index
writing-workflows/index
installing-workflows
running-workflows/index
Expand Down
Loading