Skip to content

Commit

Permalink
Merge pull request #280 from edibotopic/user-selects-docs-filetype
Browse files Browse the repository at this point in the history
User selects docs filetype
  • Loading branch information
edibotopic authored Sep 16, 2024
2 parents e8d9840 + 20654fd commit 50ec97b
Show file tree
Hide file tree
Showing 3 changed files with 120 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/test-starter-pack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ jobs:
- name: Check out repo
uses: actions/checkout@v4
- name: Run init and build
env:
default_filetype_choice: md # don't prompt for user choice
run: sp-tests/run-init-and-build.sh
- name: Add some files, build, and test
run: sp-tests/add-files-and-build.sh
Expand Down Expand Up @@ -46,6 +48,8 @@ jobs:
- name: Check out repo
uses: actions/checkout@v4
- name: Run init and build
env:
default_filetype_choice: md # don't prompt for user choice
run: sp-tests/run-init-and-build.sh docs
- name: Add some files, build, and test
run: sp-tests/add-files-and-build.sh docs
Expand Down
43 changes: 43 additions & 0 deletions init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,32 @@ if [ -z "$install_directory" ]; then
read -rp "Enter the installation directory (e.g., '.' or 'docs'): " install_directory
fi

# Check if md or rst is preferred for the documentation being built
promptForFileChoice()
{
while true; do
read -p "Will you be using the 'rst' or 'md' file format for the documentation (default: 'rst'): " filetype_choice

filetype_choice=${filetype_choice:-rst}

if [ "$filetype_choice" = "md" ] || [ "$filetype_choice" = "rst" ]; then
file_type="$filetype_choice"
echo "Setting filetype to: $file_type"
break
else
echo "Invalid input. Please enter either 'md' or 'rst':"
fi
done
}

# If default variable for filetype choice is defined in CI then don't prompt user for choice
if [ -z "${default_filetype_choice:-}" ]; then
promptForFileChoice
else
file_type="$default_filetype_choice"
echo "Using predefined filetype choice: $file_type"
fi

# Normalise the install_directory path
install_directory=$(realpath -m --relative-to="$(pwd)" "$install_directory")
echo "Installing at $install_directory..."
Expand Down Expand Up @@ -84,6 +110,23 @@ fi
echo "Copying contents to the installation directory..."
cp -R "$temp_directory"/sp-files/* "$temp_directory"/sp-files/.??* "$install_directory"

# Delete files with unpreferred filetype in the installation directory
# No wildcard delete to avoid data loss if user Git-inits in dir with pre-existing files
if [ -z "${default_filetype_choice:-}" ]; then
echo "Default filetype not defined, so proceed with deleting unpreferred filetype."
if [ "$file_type" = 'md' ]; then
echo "Deleting .rst files..."
rm "$install_directory"/doc-cheat-sheet.rst
rm "$install_directory"/index.rst
else
echo "Deleting .md files..."
rm "$install_directory"/doc-cheat-sheet-myst.md
rm "$install_directory"/index.md
fi
else
echo "Default filetype is defined, so skip filetype deletion."
fi

# Ensure GitHub workflows and woke config are placed in the repo root
# if installing in a non-root directory
if [ "$install_directory" != "." ]; then
Expand Down
73 changes: 73 additions & 0 deletions sp-files/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Starter pack

**A single sentence that says what the product is, succinctly and memorably.**
Consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et
dolore magna aliqua.

**A paragraph of one to three short sentences, that describe what the product
does.** Urna cursus eget nunc scelerisque viverra mauris in. Nibh mauris
cursus mattis molestie a iaculis at vestibulum rhoncus est pellentesque
elit. Diam phasellus vestibulum lorem sed.

**A third paragraph of similar length, this time explaining what need the
product meets.** Dui ut ornare lectus sit amet est. Nunc sed augue lacus
viverra vitae congue eu consequat ac libero id faucibus nisl tincidunt eget
nullam.

**Finally, a paragraph that describes whom the product is useful for.** Nunc
non blandit massa enim nec dui nunc mattis enim. Ornare arcu odio ut sem
nulla pharetra diam porttitor leo a diam sollicitudin tempor id eu. Ipsum
dolor sit amet consectetur adipiscing elit pellentesque habitant.

---------

## In this documentation

````{grid} 1 1 2 2
```{grid-item-card} [Tutorials](index)
**Start here**: a hands-on introduction to Example Product for new users
```
```{grid-item-card} [How-to guides](index)
**Step-by-step guides** covering key operations and common tasks
```
````

````{grid} 1 1 2 2
:reverse:
```{grid-item-card} [Reference](index)
**Technical information** - specifications, APIs, architecture
```
```{grid-item-card} [Explanations](index)
**Discussion and clarification** of key topics
```
````

---------

## Project and community

Example Project is a member of the Ubuntu family. It’s an open source project that warmly welcomes community projects, contributions, suggestions, fixes and constructive feedback.

* Code of conduct
* Get support
* Join our online chat
* Contribute
* Roadmap
* Thinking about using Example Product for your next project? Get in touch!

```{toctree}
:hidden:
:maxdepth: 2
self
```

0 comments on commit 50ec97b

Please sign in to comment.