Contributing to Documentation
Contributions to the PX4 User Guide are very welcome; from simple fixes to spelling and grammar, through to the creation of whole new sections.
This topic explains how to make and test changes. Towards the end there is a basic style guide.
Note
You will need a (free) Github account to contribute to the guides.
Quick Changes in Github
Simple changes to existing content can be made by clicking the Edit on GitHub link that appears at the bottom of every page (this opens the page on Github for editing).
To edit an existing page:
- Open the page.
- Click the Edit on GitHub link below the page content.
- Make the desired change.
- Below the Github page editor you'll be prompted to create a separate branch and then guided to submit a pull request.
The documentation team will review the request and either merge it or work with you to update it.
Changes using Git (New Pages and Images)
More substantial changes, including adding new pages or adding/modifying images, aren't as easy to make (or properly test) on Github. For these kinds of changes we suggest using the same approach as for code:
- Use the git toolchain to get the documentation source code onto your local computer.
- Modify the documentation as needed (add, change, delete).
- Test that it builds properly using Vitepress.
- Create a branch for your changes and create a pull request (PR) to pull it back into the documentation.
The following explain how to get the source code, build locally (to test), and modify the code.
Get/Push Documentation Source Code
To get the library(s) sources onto your local computer you will need to use the git toolchain. The instructions below explain how to get git and use it on your local computer.
Download git for your computer from https://git-scm.com/downloads
Sign up for Github if you haven't already
Create a copy (Fork) of the PX4 User Guide repo on Github (instructions here).
Clone (copy) your forked repository to your local computer:
shcd ~/wherever/ git clone https://github.com/<your git name>/PX4-user_guide.git
For example, to clone the PX4 userguide fork for a user with Github account "john_citizen":
shgit clone https://github.com/john_citizen/PX4-user_guide.git
Navigate to your local repository:
shcd ~/wherever/PX4-user_guide
Add a remote called "upstream" to point to the PX4 version of the library:
shgit remote add upstream https://github.com/PX4/PX4-user_guide.git
TIP
A "remote" is a handle to a particular repository. The remote named origin is created by default when you clone the repository, and points to your fork of the guide. Above you create a new remote upstream that points to the PX4 project version of the documents.
Create a branch for your changes:
shgit checkout -b <your_feature_branch_name>
This creates a local branch on your computer named
your_feature_branch_name
.Make changes to the documentation as needed (general guidance on this in following sections)
Once you are satisfied with your changes, you can add them to your local branch using a "commit":
shgit add <file name> git commit -m "<your commit message>"
For a good commit message, please refer to the Source Code Management section.
Push your local branch (including commits added to it) to your forked repository on Github.
shgit push origin your_feature_branch_name
Go to your forked repository on Github in a web browser, e.g.:
https://github.com/<your git name>/PX4-user_guide.git
. There you should see the message that a new branch has been pushed to your forked repository.Create a pull request (PR):
- On the right hand side of the "new branch message" (see one step before), you should see a green button saying "Compare & Create Pull Request". Press it.
- A pull request template will be created. It will list your commits and you can (must) add a meaningful title (in case of a one commit PR, it's usually the commit message) and message (explain what you did for what reason. Check other pull requests for comparison)
You're done! Maintainers for the PX4 User Guide will now have a look at your contribution and decide if they want to integrate it. Check if they have questions on your changes every once in a while.
Building the Library Locally
Build the library locally to test that any changes you have made have rendered properly:
Install the Vitepress prerequisites:
Navigate to your local repository:
shcd ~/wherever/PX4-user_guide
Install dependencies (including Vitepress):
shyarn install
Preview and serve the library:
shyarn start
- Once the development/preview server has built the library (less than a minute for the first time) it will show you the URL you can preview the site on. This will be something like:
http://localhost:5173/px4_user_guide/
. - Stop serving using CTRL+C in the terminal prompt.
- Once the development/preview server has built the library (less than a minute for the first time) it will show you the URL you can preview the site on. This will be something like:
You can build the library as it would be done for deployment:
sh# Ubuntu yarn docs:build # Windows yarn docs:buildwin
TIP
Use yarn start
to preview changes as you make them (documents are updated and served very quickly). Before submitting a PR you should also build it using yarn docs:build
, as this can highlight issues that are not visible when using yarn start
.
Source Code Structure
The guide uses the Vitepress toolchain.
In overview:
Pages are written in separate files using markdown.
- The syntax is almost the same as that used by the Github wiki.
- Vitepress also supports some markdown extensions. We try and avoid using these, except for tips, warning, etc.. This might be revisited - there are some interesting options provided!
This is a multilingual book:
- Pages for each language are stored in the folder named for the associated language code (e.g. "en" for English, "zh" for Chinese, "ko" for Korean).
- Only edit the ENGLISH (
/en
) version of files. We use Crowdin to manage the translations.
All pages must be in an appropriately named sub-folder of
/en
(e.g. this page is in folderen/contribute/
).- This makes linking easier because other pages and images are always as the same relative levels
The structure of the book is defined in
SUMMARY.md
.If you add a new page to the guide you must also add an entry to this file!
TIP
This is not "standard vitepress" way to define the sidebar (the summary file is imported by .vitepress/get_sidebar.js).
Images must be stored in a sub folder of
/assets
. This is two folders down from content folders, so if you add an image you will reference it like:plain![Image Description](../../assets/path_to_file/filename.jpg)
A file named package.json defines any dependencies of the build.
A web hook is used to track whenever files are merged into the master branch on this repository, causing the book to rebuild.
Adding New Pages
When you add a new page you must also add it to en/SUMMARY.md
!
Style Guide
Files/file names
- Put new markdown files in an appropriate sub-folder of
/en/
, such as/en/contribute/
. Do not further nest folders. - Put new image files in an appropriate nested sub-folder of
/assets/
. Deeper nesting is allowed/encouraged. - Use descriptive names for folders and files. In particular, image filenames should describe what they contain (don't name as "image1.png")
- Use lower case filenames and separate words using underscores (
_
).
- Put new markdown files in an appropriate sub-folder of
Images
- Use the smallest size and lowest resolution that makes the image still useful (this reduces download cost for users with poor bandwidth).
- New images should be created in a sub-folder of
/assets/
(so they can be shared between translations). - SVG files are preferred for diagrams. PNG files are preferred over JPG for screenshots.
Content:
- Use "style" (bold, emphasis, etc.) consistently and sparingly (as little as possible).
- Bold for button presses and menu definitions.
- Emphasis for tool names such as QGroundControl or prettier.
code
for file paths, and code, parameter names that aren't linked, using tools in a command line, such asprettier
.
- Headings and page titles should use "First Letter Capitalisation".
- The page title should be a first level heading (
#
). All other headings should be h2 (##
) or lower. - Don't add any style to headings.
- Don't translate the first part of an
info
,tip
orwarning
declaration (e.g.::: tip
) as this precise text is required to render the note properly. - Break lines on sentences by preference. Don't break lines based on some arbitrary line length.
- Format using prettier (VSCode is a has extensions can be used for this).
- Use "style" (bold, emphasis, etc.) consistently and sparingly (as little as possible).
Where Do I Add Changes?
Add new files in folders that cover similar topics. Then reference them in the sidebar (/en/SUMMARY.md
) in line with the existing structure!
Translations
For information about translation see: Translation.
Licence
All PX4/Dronecode documentation is free to use and modify under terms of the permissive CC BY 4.0 license.