Skip to content

Commit

Permalink
Merge pull request #286 from akcano/use-canonical-sphinx-extension
Browse files Browse the repository at this point in the history
fix: failing tests
  • Loading branch information
akcano authored Sep 26, 2024
2 parents eae3d78 + c4868a2 commit aa3d354
Show file tree
Hide file tree
Showing 10 changed files with 225 additions and 28 deletions.
8 changes: 7 additions & 1 deletion init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,18 @@ cp -R "$temp_directory"/sp-files/* "$temp_directory"/sp-files/.??* "$install_dir
# No wildcard delete to avoid data loss if user Git-inits in dir with pre-existing files
if [ "$file_type" = 'md' ]; then
echo "Deleting .rst files..."
rm "$install_directory"/contributing.rst
rm "$install_directory"/doc-cheat-sheet.rst
rm "$install_directory"/index.rst
for file in "$install_directory"/*-myst.md; do
mv "$file" "${file/-myst.md/.md}"
done

else
echo "Deleting .md files..."
rm "$install_directory"/contributing-myst.md
rm "$install_directory"/doc-cheat-sheet-myst.md
rm "$install_directory"/index.md
rm "$install_directory"/index-myst.md
fi

# Ensure GitHub workflows and woke config are placed in the repo root
Expand Down
2 changes: 1 addition & 1 deletion sp-docs/.custom_wordlist.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
WCAG
WCAG
6 changes: 6 additions & 0 deletions sp-files/.sphinx/.wordlist.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
# This wordlist is from the Sphinx starter pack and should not be
# modified. Add any custom terms to .custom_wordlist.txt instead.


ACME
ACME's
addons
AGPLv
API
APIs
balancer
Charmhub
CLI
DCO
Diátaxis
dropdown
EBS
Expand Down Expand Up @@ -53,6 +58,7 @@ RTD
subdirectories
subfolders
subtree
TODO
Ubuntu
UI
UUID
Expand Down
5 changes: 4 additions & 1 deletion sp-files/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,12 @@
###############################

# A regex list of URLs that are ignored by 'make linkcheck'
#
# TODO: Remove or adjust the ACME entry after you update the contributing guide

linkcheck_ignore = [
'http://127.0.0.1:8000'
'http://127.0.0.1:8000',
'https://github.com/canonical/ACME/*'
]


Expand Down
183 changes: 183 additions & 0 deletions sp-files/contributing-myst.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
---
orphan: true
---

<!-- TODO: Replace all mentions of ACME with your project name -->
<!-- TODO: Update all sections containing TODOs; make sure no TODOs are left -->

# How to contribute

We believe that everyone has something valuable to contribute, whether you're a coder, a writer, or a tester. Here's how and why you can get involved:

- **Why join us?** Work with like-minded people, develop your skills, connect with diverse professionals, and make a difference.
- **What do you get?** Personal growth, recognition for your contributions, early access to new features, and the joy of seeing your work appreciated.
- **Start early, start easy**: Dive into code contributions, improve documentation, or be among the first testers. Your presence matters, regardless of experience or the size of your contribution.

The guidelines below will help keep your contributions effective and meaningful.

## Code of conduct

When contributing, you must abide by the [Ubuntu Code of Conduct](https://ubuntu.com/community/ethos/code-of-conduct).

## Licence and copyright

<!-- TODO: Update with your license details or drop if excessive -->

By default, all contributions to ACME are made under the AGPLv3 licence. See the [licence](https://github.com/canonical/ACME/blob/main/COPYING) in the ACME GitHub repository for details.

All contributors must sign the [Canonical contributor licence agreement](https://ubuntu.com/legal/contributors), which grants Canonical permission to use the contributions. The author of a change remains the copyright owner of their code (no copyright assignment occurs).

## Releases and versions

<!-- TODO: Add your release and versioning details or drop if excessive -->

ACME uses [semantic versioning](https://semver.org/); major releases occur once or twice a year.

The release notes can be found TODO: [here](https://example.com).

## Environment setup

<!-- TODO: Update with your prerequisites or drop if excessive -->

To work on the project, you need the following prerequisites:

- [TODO: Prerequisite 1](http://example.com)
- [TODO: Prerequisite 2](http://example.com)

To install and configure these tools:

```bash
TODO: prerequisite command 1
TODO: prerequisite command 2
```

## Submissions

<!-- TODO: Suggest your own PR process or drop if excessive -->

If you want to address an issue or a bug in ACME, notify in advance the people involved to avoid confusion; also, reference the issue or bug number when you submit the changes.

- Fork [our GitHub repository](https://github.com/canonical/ACME) and add the changes to your fork, properly structuring your commits, providing detailed commit messages, and signing your commits.

- Make sure the updated project builds and runs without warnings or errors; this includes linting, documentation, code, and tests.

- Submit the changes as a [pull request (PR)](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request-from-a-fork).

Your changes will be reviewed in due time; if approved, they will eventually be merged.

### Describing pull requests

<!-- TODO: Update with your own checklist or drop if excessive -->

To be properly considered, reviewed, and merged, your pull request must provide the following details:

- **Title**: Summarise the change in a short, descriptive title.
- **Description**: Explain the problem that your pull request solves. Mention any new features, bug fixes, or refactoring.
- **Relevant issues**: Reference any [related issues, pull requests, and repositories](https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/autolinked-references-and-urls).
- **Testing**: Explain whether new or updated tests are included.
- **Reversibility**: If you propose decisions that may be costly to reverse, list the reasons and suggest steps to reverse the changes if necessary.

### Commit structure and messages

<!-- TODO: Update with your own guidelines or drop if excessive -->

Use separate commits for each logical change, and for changes to different components. Prefix your commit messages with the names of components they affect, using the code tree structure. For example, start a commit that updates the ACME service with `ACME/service:`.

Use [conventional commits](https://www.conventionalcommits.org/) to ensure consistency across the project:

```none
Ensure correct permissions and ownership for the content mounts
* Work around an ACME issue regarding empty dirs: https://github.com/canonical/ACME/issues/12345
* Ensure the source directory is owned by the user running a container.
Links:
- ...
- ...
```

Such structure makes it easier to review contributions and simplifies porting fixes to other branches.

### Signing commits

<!-- TODO: Update with your suggestions or drop if excessive -->

To improve contribution tracking, we use the developer certificate of origin ([DCO 1.1](https://developercertificate.org/)) and require a "sign-off" for any changes going into each branch.

The sign-off is a simple line at the end of the commit message certifying that you wrote it or have the right to commit it as an open-source contribution.

To sign off on a commit, use the `--signoff` option in `git commit`.

## Code

### Formatting and linting

<!-- TODO: Update with your linting configuration setup or drop if excessive -->

ACME relies on these formatting and linting tools:

- [TODO: Tool 1](http://example.com)
- [TODO: Tool 2](http://example.com)

To configure and run them:

```bash
TODO: lint command 1
TODO: lint command 2
```

### Structure

- **Check linked code elements**: Ensure coupled code elements, files, and directories are adjacent. For instance, store test data close to the corresponding test code.
- **Group variable declaration and initialisation**: Declare and initialise variables together to improve code organisation and readability.
- **Split large expressions**: Break down large expressions into smaller self-explanatory parts. Use multiple variables where appropriate to make the code more understandable and choose names that reflect their purpose.
- **Use blank lines for logical separation**: Insert a blank line between two logically separate sections of code to improve its structure and readability.
- **Avoid nested conditions**: Avoid nesting conditions to improve readability and maintainability.
- **Remove dead code and redundant comments**: Drop unused or obsolete code and comments to promote a cleaner code base and reduce confusion.
- **Normalise symmetries**: Treat identical operations consistently, using a uniform approach to improve consistency and readability.

### Best practices

<!-- TODO: Update with your best practices or drop if excessive -->

## Tests

<!-- TODO: Update with your testing framework details or drop if excessive -->

All code contributions must include tests.

To run the tests locally before submitting your changes:

```bash
TODO: test command 1
TODO: test command 2
```

## Documentation

ACME's documentation is stored in the `DOCDIR` directory of the repository. It is based on the [Canonical starter pack](https://canonical-starter-pack.readthedocs-hosted.com/latest/) and hosted on [Read the Docs](https://about.readthedocs.com/).

For general guidance, refer to the [starter pack guide](https://canonical-starter-pack.readthedocs-hosted.com/latest/readme/).

For syntax help and guidelines, refer to the [Canonical style guides](https://canonical-documentation-with-sphinx-and-readthedocscom.readthedocs-hosted.com/#style-guides).

In structuring, the documentation employs the [Diátaxis](https://diataxis.fr/) approach.

To run the documentation locally before submitting your changes:

```bash
make run
```

### Automatic checks

GitHub runs automatic checks on the documentation to verify spelling, validate links, and suggest inclusive language.

You can (and should) run the same checks locally:

```bash
make spelling
make linkcheck
make woke
```
6 changes: 4 additions & 2 deletions sp-files/contributing.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
:orphan:

.. TODO: Replace all mentions of ACME with your project name
.. TODO: Update all sections containing TODOs; make sure no TODOs are left
Expand Down Expand Up @@ -77,8 +79,8 @@ To install and configure these tools:
TODO: prerequisite command 2
Submitting changes
------------------
Submissions
-----------

.. TODO: Suggest your own PR process or drop if excessive
Expand Down
1 change: 1 addition & 0 deletions sp-files/index.md → sp-files/index-myst.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,5 @@ Example Project is a member of the Ubuntu family. It’s an open source project
:maxdepth: 2
self
contributing
```
40 changes: 17 additions & 23 deletions sp-tests/add-files-and-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,26 @@ set -ex

source sp-tests/get-installation-directory.sh

# Copy the test files
cp sp-tests/testfiles/test-md.md testdir/$install_directory/
cp sp-tests/testfiles/test-rst.rst testdir/$install_directory/

# Include the files in the toctree
if ! grep -Fxq " test-md" testdir/$install_directory/index.rst
if [ -f "testdir/$install_directory/index.md" ];
then
echo " test-md" >> testdir/$install_directory/index.rst
echo " test-rst" >> testdir/$install_directory/index.rst
fi
cp sp-tests/testfiles/test-md.md "testdir/$install_directory/"
sed -i 's/contributing/test-md/g' "testdir/$install_directory/index.md"

# Build the documentation
cd testdir/$install_directory
make html
cd testdir/$install_directory
make html

# Test the output
if ! grep -Fq "A documentation starter-pack" _build/test-md/index.html || \
! grep -Fq "A documentation starter-pack" _build/test-rst/index.html
then
echo "Related links don't work (in RST or Markdown)"
exit 1
fi
grep -Fq "A documentation starter-pack" _build/test-md/index.html
grep -Fq "Open Documentation Hour" _build/test-md/index.html

if ! grep -Fq "Open Documentation Hour" _build/test-md/index.html || \
! grep -Fq "Open Documentation Hour" _build/test-rst/index.html
elif [ -f "testdir/$install_directory/index.rst" ];
then
echo "Discourse links don't work (in RST or Markdown)"
exit 1
cp sp-tests/testfiles/test-rst.rst "testdir/$install_directory/"
sed -i 's/contributing/test-rst/g' "testdir/$install_directory/index.rst"

cd testdir/$install_directory
make html

grep -Fq "A documentation starter-pack" _build/test-rst/index.html
grep -Fq "Open Documentation Hour" _build/test-rst/index.html
fi

1 change: 1 addition & 0 deletions sp-tests/testfiles/test-md.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
---
orphan: true
discourse: 42771
relatedlinks: https://github.com/canonical/sphinx-docs-starter-pack
---
Expand Down
1 change: 1 addition & 0 deletions sp-tests/testfiles/test-rst.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
:orphan:
:discourse: 42771
:relatedlinks: https://github.com/canonical/sphinx-docs-starter-pack

Expand Down

0 comments on commit aa3d354

Please sign in to comment.