Skip to content

Commit 8bb3ec7

Browse files
committed
Move most of the README to docs/index.md
Once the `index.md` (home) of the generated documentation gets complex, it doesn't make a lot of sense to reuse the README, because: 1. More advanced `mkdocs` syntax is not rendered properly by GitHub (like admonitions). 2. Internal cross-linking into the documentation from the home also doesn't work in GitHub. Because of this we leave a much sorter and simpler README, with a quick example, and for the rest we point users to the documentation website. Signed-off-by: Leandro Lucarella <[email protected]>
1 parent a937e16 commit 8bb3ec7

File tree

2 files changed

+236
-184
lines changed

2 files changed

+236
-184
lines changed

README.md

Lines changed: 7 additions & 183 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,7 @@ If offers:
1212
checks.
1313
* Tools to build protobuf/grpc files as Python, including type information.
1414

15-
16-
[Cookiecutter]: https://cookiecutter.readthedocs.io/en/stable
17-
18-
## Usage
19-
20-
### Start a new project
15+
## Quick Example
2116

2217
To start a new project you should first [install
2318
Cookiecutter](https://cookiecutter.readthedocs.io/en/stable/installation.html).
@@ -51,186 +46,15 @@ After completing it and fixing the `TODO`s you can amend the previous commit
5146
using `git commit --amend` or create a new commit for the changes using `git
5247
commit`.
5348

54-
#### Create the local development environment
55-
56-
To start the development, you need to make sure your environment is correctly
57-
setup. One way to do this is by using a virtual environment and installing all
58-
the dependencies there:
59-
60-
```sh
61-
# requires at least python version 3.11
62-
python3 -m venv .venv
63-
. .venv/bin/activate
64-
pip install -e .[dev]
65-
```
66-
67-
This will install you package in [*editable*
68-
mode](https://setuptools.pypa.io/en/latest/userguide/development_mode.html), so
69-
you can open a python interpreter and import your package modules and pick up
70-
any local changes without the need to reinstall. You can now run tools
71-
directly, like `pytest`.
72-
73-
#### Verify the new repository is healthy using `nox`
74-
75-
If you prefer to keep your virtual enviroment cleaner and avoid installing development dependencies, you can also use `nox` to create isolated environments for you:
76-
77-
```sh
78-
pip install -e .[dev-noxfile]
79-
nox --install-only # Set up virtual environments once
80-
nox -R # Run linting and testing reusing the already existing virtual environments
81-
```
82-
83-
This will only install you package in *editable* mode and the minimum
84-
dependencies to be able to run `nox`, and then run all `nox` default sessions,
85-
which will run linters and tests.
86-
87-
!!! note
88-
89-
It's much faster to use `nox` with `--install-only` once (each time to
90-
change or update dependencies you need to run it again) and then using `nox
91-
-R` to run the sessions without re-creating the virtual environments.
92-
93-
Otherwise `nox` will create many virtual environments each time you run it,
94-
which is **very** slow.
95-
96-
#### Verify the generated documentation works
97-
98-
To generate the documentation you can use `mkdocs`:
99-
100-
```sh
101-
pip install .[dev-mkdocs] # Not necessary if you already installed .[dev]
102-
mkdocs serve
103-
```
104-
105-
If the command fails, look at the log warnings and errors and fix them. If it
106-
worked, now there is a local web server serving the documentation, you can
107-
point your browser to Now you can point your browser to
108-
[http://127.0.0.1:8000](/http://127.0.0.1:8000/) to have a look.
109-
110-
!!! info
111-
112-
For API projects `docker` is needed to generate and serve documentation, as
113-
the easiest way to use the [tool to generate the documentation from
114-
`.proto`](https://github.com/pseudomuto/protoc-gen-doc) files is using
115-
`docker`.
116-
117-
#### Initialize the GitHub pages website
118-
119-
The generated documentation can be easily published via GitHub pages, and it
120-
will be automatically updated for new pushed and releases, but for that to work
121-
correctly, some initial setup is needed:
122-
123-
```sh
124-
pip install -e .[dev-mkdocs] # Not necessary if you already installed .[dev]
125-
mike deploy --update-aliases next latest # Creates the branch gh-pages locally
126-
mike set-default latest # Makes the latest alias the default version
127-
git push upstream gh-pages # Pushes the new branch upstream so the website is published
128-
```
129-
130-
Then make sure that GitHub pages is enabled in
131-
`https://github.com/<repo-owner>/<repo-name>/settings/pages`.
132-
133-
If all went well, your website should be available soon via
134-
`https://<repo-owner>.github.io//<repo-name>/`.
49+
## Documentation
13550

136-
### Migrate an existing project
137-
138-
The easiest way to migrate an existing project is to just generate a new one
139-
basing all the inputs in the current project metadata and then overwritting the
140-
existing files.
141-
142-
It is recommended to commit all changes before doing this, so you can then use
143-
`git` to look at the changes.
144-
145-
If you generate the new repo in a temporary directory, you can easily overwrite
146-
the files in your existing project by using `rsync` or similar tools:
147-
148-
```sh
149-
cd /tmp
150-
cookiecutter gh:frequenz-floss/frequenz-repo-config-python --directory=cookiecutter
151-
rsync -vr --exclude=.git/ new-project/ /path/to/existing/project
152-
cd /path/to/existing/project
153-
git diff
154-
# Fix all the `TODO`s and cleanup the generated files
155-
git commit -a
156-
```
157-
158-
!!! warning
159-
160-
The trailing slash in `new-project/` and the lack of it in
161-
`/path/to/existing/project` are meaningful to `rsync`.
162-
163-
Also make sure to **exclude** the `.git/` directory to avoid messing up
164-
with your local git repository.
165-
166-
!!! tip
167-
168-
Please have a look at the follow-up steps listed in the [Start a new
169-
project](#create-the-local-development-environment) section to finish the
170-
setup.
171-
172-
### Update an existing project
173-
174-
To update an existing project you can use the [Cookiecutter *replay
175-
file*](https://cookiecutter.readthedocs.io/en/stable/advanced/replay.html) that
176-
was saved during the project generation. The file is saved in
177-
`.cookiecutter-replay.json`. Using this file you can re-run Cookiecutter
178-
without having to enter all the inputs again.
179-
180-
!!! warning
181-
182-
Don't forget to commit all changes in your repository before doing this!
183-
Files will be overwritten!
184-
185-
```sh
186-
git commit -a # commit all changes
187-
cd ..
188-
cookiecutter gh:frequenz-floss/frequenz-repo-config-python \
189-
--directory=cookiecutter \
190-
--force \
191-
--replay \
192-
--replay-file project-directory/.cookiecutter-replay.json
193-
```
194-
195-
This will create a new commit with all the changes to the overwritten files.
196-
Bear in mind that all the `TODO`s will come back, so there will be quite a bit
197-
of cleanup to do. You can easily check what was changed using `git show`, and
198-
you can use `git commit --amend` to amend the previous commit with the template
199-
updates, or create a new commit with the fixes. You can also use `git citool`
200-
or `git gui` to easily add, remove or even discard (revert) changes in the
201-
templates update commit.
202-
203-
!!! note
204-
205-
The `project-directory` is the directory of your previously generated
206-
project. If you renamed it, then the files will be generated in a new
207-
directory with the original name. You can update the target directory in
208-
the replay file.
209-
210-
!!! note
211-
212-
Please remember to keep your replay file up to date if you change any
213-
metadata in the project.
214-
215-
!!! tip
216-
217-
Please have a look at the follow-up steps listed in the [Start a new
218-
project](#create-the-local-development-environment) section to finish the
219-
setup.
220-
221-
## Advanced usage
222-
223-
The Cookiecutter template uses some tools provided as a library by this
224-
project.
225-
226-
Usually users don't need deal with it directly, but if you project needs some
227-
extra customization (like disabling `nox` sessions or adding new ones, or using
228-
different CLI options for some tools), then you'll need to.
229-
230-
You can find information about the extra features in the [API
231-
refence](reference/frequenz/repo/config/).
51+
For more detailed documentation please check the [project's
52+
website](https://frequenz-floss.github.io/frequenz-repo-config-python/).
23253

23354
## Contributing
23455

23556
If you want to know how to build this project and contribute to it, please
23657
check out the [Contributing Guide](CONTRIBUTING.md).
58+
59+
60+
[Cookiecutter]: https://cookiecutter.readthedocs.io/en/stable

0 commit comments

Comments
 (0)