Welcome stranger!
If you have come here to learn how to contribute to mdBook, we have some tips for you!
First of all, don't hesitate to ask questions! Use the issue tracker, no question is too simple.
Before working on pull request, please ping us on the corresponding issue.
The current PR backlog is beyond what we can process at this time.
Only issues that have an E-Help-wanted
or Feature accepted
label will likely receive reviews.
If there isn't already an open issue for what you want to work on, please open one first to see if it is something we would be available to review.
If you are starting out, you might be interested in the E-Easy issues. Those are issues that are considered more straightforward for beginners to Rust or the codebase itself. These issues can be a good launching pad for more involved issues. Easy tasks for a first time contribution include documentation improvements, new tests, examples, updating dependencies, etc.
If you come from a web development background, you might be interested in issues related to web technologies tagged A-JavaScript, A-Style, A-HTML or A-Mobile.
When you decide you want to work on a specific issue, and it isn't already assigned to someone else, assign the issue to yourself by leaving a comment with the text @rustbot claim
.
Again, do not hesitate to ask questions. We will gladly mentor anyone that want to tackle an issue.
Issues on the issue tracker are categorized with the following labels:
- A-prefixed labels state which area of the project an issue relates to.
- E-prefixed labels show an estimate of the experience necessary to fix the issue.
- M-prefixed labels are meta-issues regarding the management of the mdBook project itself
- S-prefixed labels show the status of the issue
- C-prefixed labels show the category of issue
mdBook builds on stable Rust, if you want to build mdBook from source, here are the steps to follow:
-
Navigate to the directory of your choice
-
Clone this repository with git.
git clone https://github.com/rust-lang/mdBook.git
-
Navigate into the newly created
mdBook
directory -
Run
cargo build
The resulting binary can be found in mdBook/target/debug/
under the name mdbook
or mdbook.exe
.
We love code quality and Rust has some excellent tools to assist you with contributions.
Before you make your Pull Request to the project, please run it through the rustfmt
utility.
This will ensure we have good quality source code that is better for us all to maintain.
rustfmt has a lot more information on the project. The quick guide is
- Install it (
rustfmt
is usually installed by default via rustup):rustup component add rustfmt
- You can now run
rustfmt
on a single file simply by...... or you can format the entire project withrustfmt src/path/to/your/file.rs
When run throughcargo fmt
cargo
it will format all bin and lib files in the current package.
For more information, such as running it from your favourite editor, please see the rustfmt
project. rustfmt
Clippy is a code analyser/linter detecting mistakes, and therefore helps to improve your code.
Like formatting your code with rustfmt
, running clippy regularly and before your Pull Request will help us maintain awesome code.
- To install
rustup component add clippy
- Running clippy
cargo clippy
Please consider the following when making a change:
-
Almost all changes that modify the Rust code must be accompanied with a test.
-
Almost all features and changes must update the documentation. mdBook has the mdBook Guide whose source is at https://github.com/rust-lang/mdBook/tree/master/guide.
-
Almost all Rust items should be documented with doc comments. See the Rustdoc Book for more information on writing doc comments.
-
Breaking the API can only be done in major SemVer releases. These are done very infrequently, so it is preferred to avoid these when possible. See SemVer Compatibility for more information on what a SemVer breaking change is.
(Note: At this time, some SemVer breaking changes are inevitable due to the current code structure. An example is adding new fields to the config structures. These are intended to be fixed in the next major release.)
-
Similarly, the CLI interface is considered to be stable. Care should be taken to avoid breaking existing workflows.
-
Check out the Rust API Guidelines for guidelines on designing the API.
When you feel comfortable that your changes could be integrated into mdBook, you can create a pull-request on GitHub. One of the core maintainers will then approve the changes or request some changes before it gets merged.
That's it, happy contributions! 🎉 🎉 🎉
Currently we don't have a strict browser compatibility matrix due to our limited resources. We generally strive to keep mdBook compatible with a relatively recent browser on all of the most major platforms. That is, supporting Chrome, Safari, Firefox, Edge on Windows, macOS, Linux, iOS, and Android. If possible, do your best to avoid breaking older browser releases.
Any change to the HTML or styling is encouraged to manually check on as many browsers and platforms that you can. Unfortunately at this time we don't have any automated UI or browser testing, so your assistance in testing is appreciated.
The following are instructions for updating highlight.js.
- Clone the repository at https://github.com/highlightjs/highlight.js
- Check out a tagged release (like
10.1.1
). - Run
npm install
- Run
node tools/build.js :common apache armasm coffeescript d handlebars haskell http julia nginx nim properties r scala x86asm yaml
- Compare the language list that it spits out to the one in
syntax-highlighting.md
. If any are missing, add them to the list and rebuild (and update these docs). If any are added to the common set, add them tosyntax-highlighting.md
. - Copy
build/highlight.min.js
to mdbook's directoryhighlight.js
. - Be sure to check the highlight.js CHANGES for any breaking changes. Breaking changes that would affect users will need to wait until the next major release.
- Build mdbook with the new file and build some books with the new version and compare the output with a variety of languages to see if anything changes. The test_book contains a chapter with many languages to examine.
Instructions for mdBook maintainers to publish a new release:
- Create a PR to update the version and update the CHANGELOG:
- Update the version in
Cargo.toml
- Run
cargo test
to verify that everything is passing, and to updateCargo.lock
. - Double-check for any SemVer breaking changes.
Try
cargo-semver-checks
, though beware that the current version of mdBook isn't properly adhering to SemVer due to the lack of#[non_exhaustive]
and other issues. See rust-lang#1835. - Update
CHANGELOG.md
with any changes that users may be interested in. - Update
continuous-integration.md
to update the version number for the installation instructions. - Commit the changes, and open a PR.
- Update the version in
- After the PR has been merged, create a release in GitHub. This can either be done in the GitHub web UI, or on the command-line:
MDBOOK_VERS="`cargo read-manifest | jq -r .version`" ; \ gh release create -R rust-lang/mdbook v$MDBOOK_VERS \ --title v$MDBOOK_VERS \ --notes "See https://github.com/rust-lang/mdBook/blob/master/CHANGELOG.md#mdbook-${MDBOOK_VERS//.} for a complete list of changes."