Skip to content

Add rustpkg tutorial to the official tutorials. #9439

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions doc/tutorial-rustpkg.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ package up your Rust code and share it with other people. This tutorial will
get you started on all of the concepts and commands you need to give the gift
of Rust code to someone else.

## Installing External Packages
# Installing External Packages

First, let's try to use an external package somehow. I've made a sample package
called `hello` to demonstrate how to do so. Here's how `hello` is used:
Expand Down Expand Up @@ -68,7 +68,7 @@ Hello, world.

Simple! That's all it takes.

## Workspaces
# Workspaces

Before we can talk about how to make packages of your own, you have to
understand the big concept with `rustpkg`: workspaces. A 'workspace' is simply
Expand All @@ -88,14 +88,14 @@ There are also default file names you'll want to follow as well:
* `main.rs`: A file that's going to become an executable.
* `lib.rs`: A file that's going to become a library.

## Building your own Package
# Building your own Package

Now that you've got workspaces down, let's build your own copy of `hello`. Go
to wherever you keep your personal projects, and let's make all of the
directories we'll need. I'll refer to this personal project directory as
`~/src` for the rest of this tutorial.

### Creating our workspace
## Creating our workspace

~~~ {.notrust}
$ cd ~/src
Expand Down Expand Up @@ -150,15 +150,15 @@ pub fn world() {

Put this into `src/hello/lib.rs`. Let's talk about each of these attributes:

### Crate attributes for packages
## Crate attributes for packages

`license` is equally simple: the license we want this code to have. I chose MIT
here, but you should pick whatever license makes the most sense for you.

`desc` is a description of the package and what it does. This should just be a
sentence or two.

### Building your package
## Building your package

Building your package is simple:

Expand Down Expand Up @@ -206,7 +206,7 @@ note: Installed package github.com/YOUR_USERNAME/hello-0.1 to /home/yourusername

That's it!

## More resources
# More resources

There's a lot more going on with `rustpkg`, this is just to get you started.
Check out [the rustpkg manual](rustpkg.html) for the full details on how to
Expand Down
2 changes: 1 addition & 1 deletion doc/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -3023,7 +3023,7 @@ There is further documentation on the [wiki], however those tend to be even more
[tasks]: tutorial-tasks.html
[macros]: tutorial-macros.html
[ffi]: tutorial-ffi.html
[rustpkg]: rustpkg.html
[rustpkg]: tutorial-rustpkg.html

[wiki]: https://github.com/mozilla/rust/wiki/Docs

10 changes: 10 additions & 0 deletions mk/docs.mk
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,16 @@ doc/tutorial-conditions.html: tutorial-conditions.md doc/version_info.html doc/r
--include-before-body=doc/version_info.html \
--output=$@

DOCS += doc/tutorial-rustpkg.html
doc/tutorial-rustpkg.html: tutorial-rustpkg.md doc/version_info.html doc/rust.css
@$(call E, pandoc: $@)
$(Q)$(CFG_NODE) $(S)doc/prep.js --highlight $< | \
$(CFG_PANDOC) --standalone --toc \
--section-divs --number-sections \
--from=markdown --to=html --css=rust.css \
--include-before-body=doc/version_info.html \
--output=$@

ifeq ($(CFG_PDFLATEX),)
$(info cfg: no pdflatex found, omitting doc/rust.pdf)
else
Expand Down