-
Notifications
You must be signed in to change notification settings - Fork 0
docs: 📝 add guide for contributing built-in styles #148
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
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
5f76e4f
docs: :memo: add guide for contributing built-in styles
martonvago 5891565
docs: :memo: add to menu; fix link
martonvago 763857e
fix: :bug: use new style in example
martonvago e4d52be
Merge branch 'main' into docs/contribute-style
martonvago c479f45
Merge branch 'main' into docs/contribute-style
lwjohnst86 00998de
:docs: :memo: apply suggestions from code review
martonvago dbb38d6
docs: :memo: fix review markups
martonvago bdc0fb9
Merge branch 'main' into docs/contribute-style
lwjohnst86 7e5eee1
docs: :memo: review markups
martonvago 72861db
Merge branch 'docs/contribute-style' of https://github.com/seedcase-p…
martonvago 4cfc25b
style: :art: format markdown
martonvago ab345ce
docs: :memo: change links
martonvago b894739
docs: :memo: apply suggestions from code review
martonvago 7179991
style: :art: format markdown
martonvago adcea9c
docs: :pencil2: weird character
lwjohnst86 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,110 @@ | ||
| --- | ||
| title: "Contributing a built-in style" | ||
| description: "Add your own style as a built-in style in Flower." | ||
| order: 4 | ||
| --- | ||
|
|
||
| Flower comes with a number of | ||
| [built-in styles](/docs/design/interface/outputs.qmd#built-in-styles) to | ||
| use with the `build` or `view` commands. This guide explains how to | ||
| contribute a new built-in style that will be available to all Flower | ||
| users. | ||
|
|
||
| Before you begin, fork the Flower repository on GitHub and clone your | ||
| fork locally. Make the following changes in your local copy. | ||
|
|
||
| ## Creating a new style | ||
|
|
||
| Built-in styles consist of the following files: | ||
|
|
||
| - Jinja2 template files: these define the layout of the generated | ||
| documentation. | ||
| - A `sections.toml` configuration file: this defines how many output | ||
| files will be created and which metadata will be displayed in each | ||
| file. | ||
|
|
||
| First, | ||
| [create the template files](/docs/guide/custom-styles.qmd#creating-the-templates) | ||
| and | ||
| [add the `sections.toml` configuration file](/docs/guide/custom-styles.qmd#sections.toml-configuration-file) | ||
| for your style by following the guide for creating custom styles. If you | ||
| are writing a terminal style for use with the `view` command, do not put | ||
| an `output-path` for your sections in `sections.toml`. | ||
|
|
||
| Use the name of your style as the name of the template folder. The name | ||
| should be short, descriptive, and distinct from existing built-in | ||
| styles. It should be given in snake case. | ||
|
|
||
| ## Adding the style as built-in | ||
|
|
||
| Next, in your local copy of the Flower repo, place the template folder | ||
| into the `src/seedcase_flower/styles/` folder. The file structure should | ||
| now look like: | ||
|
|
||
| ``` txt | ||
| src/ | ||
| └── seedcase_flower/ | ||
| └── styles/ | ||
| ├── ... | ||
| └── your_new_style/ | ||
| ├── sections.toml | ||
| ├── template_1.qmd.jinja | ||
| ├── template_2.qmd.jinja | ||
| ├── ... | ||
| └── template_last.qmd.jinja | ||
| ``` | ||
|
|
||
| Finally, add your style to the appropriate style enum (`BuildStyle` or | ||
| `ViewStyle`) in `src/seedcase_flower/internals.py`. Styles used with the | ||
| `build` command are defined in the `BuildStyle` enum, while styles used | ||
| with `view` are defined in `ViewStyle`. For example, if the | ||
| `your_new_style` is a style for `build`, you would include it like so: | ||
|
|
||
| ``` {.python filename="src/seedcase_flower/internals.py"} | ||
| class BuildStyle(Enum): | ||
| """Built-in styles for outputting to file.""" | ||
|
|
||
| quarto_one_page = "quarto_one_page" | ||
| quarto_resource_listing = "quarto_resource_listing" | ||
| quarto_resource_tables = "quarto_resource_tables" | ||
| your_new_style = "your_new_style" # <1> | ||
| ``` | ||
|
|
||
| 1. Add your new style as shown on this line. | ||
|
|
||
| ::: callout-important | ||
| For the new style to work properly, the name of the enum member must be | ||
| exactly the same as the folder name for the new style. | ||
lwjohnst86 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ::: | ||
|
|
||
| ## Testing the new style | ||
lwjohnst86 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| Once the new style is in place, be sure to test that it works as | ||
| expected by running the `view` or `build` command as appropriate. You | ||
| can use the example Data Package included in Flower to test: | ||
|
|
||
| ``` {.bash filename="Terminal"} | ||
| uv run seedcase-flower build --uri docs/includes/datapackage.json --style your-new-style | ||
lwjohnst86 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ``` | ||
|
|
||
| ## Making a pull request | ||
|
|
||
| Before submitting a pull request with your changes, make sure you: | ||
|
|
||
| - Run `just run-all` in the terminal. | ||
| - Put your changes on a new branch with a name that follows our | ||
| [branch naming conventions](https://guidebook.seedcase-project.org/workflows/prs#branch-naming-conventions). | ||
| - Commit your changes following | ||
| [Conventional Commits](https://guidebook.seedcase-project.org/workflows/commits#conventional-commits). | ||
| - Push your branch to GitHub. | ||
|
|
||
| You might find it helpful to read through our | ||
| [contributing guidelines](/CONTRIBUTING.html). If you would like a more | ||
| detailed walkthrough of | ||
| [creating commits](https://guidebook.seedcase-project.org/workflows/commits) | ||
| and | ||
| [submitting pull requests](https://guidebook.seedcase-project.org/workflows/prs), | ||
| have a look at the relevant sections of our Guidebook. | ||
|
|
||
| You're now ready to open a pull request from your fork to the main | ||
| Flower repository on GitHub. | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.