Skip to content
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

doc (book): add "Getting Started" subsection: "Essential Terminology" #8855

Merged
merged 14 commits into from
Nov 25, 2020

Conversation

salewski
Copy link
Contributor

@salewski salewski commented Nov 13, 2020

Reworked PR (2020-11-21)

Fixes #8854

In The Cargo Book, beef-up the glossary, and provide hyperlinks to the definitions of key terms through both the "Getting Started" and "Cargo Guide" chapters.

In addition to the links, some transitional text (two sentences) has been added to the beginning of "First Steps with Cargo", and somewhat more to "Why Cargo Exists" in the guide. The intent is cater to readers jumping into this book cold, or perhaps coming from the "Hello, Cargo!" section at the beginning of The Book. The changes assume a knowledgeable but skeptical user, so take pains to justify the reader's attention. A developer that knows very little about Rust and nothing about Cargo and can follow the text and map Cargo-specific concepts to analogues in other language ecosystems.

Within the glossary many terms are touched-up, as described in the commit message for the first patch in the series. Intra-glossary links are added between all terms.

In the "Getting Started" and "Cargo Guide" chapters, terms are linked to their glossary entries throughout, for the first mention of a term within a given section. The first time a term is seen in the chapter, the markdown syntax for italics is used. In "First Steps with Cargo", both italics and bold markdown are used, in keeping with the existing styling.

Orig PR (2020-11-12) -- obsolete

Insert short terminology cheatsheet page to explain these terms:

  • package
  • crate
    • library crate
    • binary crate
  • module
  • workspace

Important in these definitions is the fact that a single package is defined by
a single 'Cargo.toml' file, and that a non-workspace Cargo.toml package
contains one or more crates.

The last two terms in the list are just glossed over, as it is more important
that the user know that the terms exist, and that there are both lower-level
(module) and higher-level (workspace) concepts than the organizational units
(a package and its crates) that feature most prominently in basic cargo
builds.

With the addition of this new "Essential Terminology" page, the structure at
the beginning of The Cargo Book is:

Introduction
1. Getting Started
    1.1. Essential Terminology      <= new
    1.2. Installation
    1.3. First Steps with Cargo
2. Cargo Guide
...

The terms in the above list are all well defined elsewhere in the Rust and
Cargo documentation, but a new user encountering them for the first time
should not need to hunt them down.

Since the opening sections of the Cargo book are among the first documents a
new user is likely to encounter, we are providing a little cheatsheet of the
essentials at this stage. Defining the above terms gives the reader a good
foothold to map concepts they may be familiar with from other languages onto
their Rust counterparts (roughly speaking).

Closes #8854

@rust-highfive
Copy link

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @alexcrichton (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Nov 13, 2020
@salewski salewski marked this pull request as ready for review November 13, 2020 02:57
@alexcrichton
Copy link
Member

Thanks for the PR! Given the prominence of this in the documentation I'd like to consider this carefully since it has the potential to affect many newcomers. To me this seems a bit out-of-place in the documentation and has a bit of a "bolt on after the fact" kind of feeling. I think ideally we would introduce these terms and explain them as part of the natural process of learning Cargo, not necessarily introducing what we might talk about later before we get there.

Did you find the existing intro docs lacking? Are terms introduced or used without much explanation as to what they are? If so could those locations perhaps get fixed?

@salewski
Copy link
Contributor Author

salewski commented Nov 16, 2020

Thanks for the PR! Given the prominence of this in the documentation I'd like to consider this carefully since it has the potential to affect many newcomers. To me this seems a bit out-of-place in the documentation and has a bit of a "bolt on after the fact" kind of feeling. I think ideally we would introduce these terms and explain them as part of the natural process of learning Cargo, not necessarily introducing what we might talk about later before we get there.

Did you find the existing intro docs lacking? Are terms introduced or used without much explanation as to what they are? If so could those locations perhaps get fixed?

In general, I find the Rust documentation to be excellent, and am often impressed with the clarity with which specific topics are explained. But I do think The Cargo Book could benefit from conceptually "picking up from" where the section 1.3. ("Hello, Cargo!") leaves off in The Book, as I'll elaborate on more below.

Before I get to that, though, I'll mention that I'd like to rescind this PR in its current form.

Thanks for your comments, @alexcrichton. The process of responding to them has lead me to reconsider the "Essential Terminology" section. I agree that it does have a "bolted-on" feel, which is not the way to go.

Over the next few days I'd like to rework the PR to introduce the terms where they are first used, but point the reader to specific entries in the glossary within The Cargo Book to get the full definitions. I'll also revisit the definition pieces from my initial PR; I'll drop those bits that are redundant with the material already present in the glossary, and maybe patch-in any remaining tidbits that might enhance the existing definitions.

With that said, allow me to provide some additional context around where I see a gap in the docs.

I think the motivation can best be understood from the perspective of an experienced developer who has worked with the tooling in other language ecosystems, and wants to kick the tires on Rust. Such a user is not necessarily committed to using Rust, and may be somebody who has looked at it before and is now circling back to get a sense for how it has matured since "the last time".

Such a user will likely start with The Book, the beginning of which is structured like this:

    Introduction
    1. Getting Started
        1.1. Installation
        1.2. Hello, World!
        1.3. Hello, Cargo!
    2. Programming a Guessing Game
    ...

As likely as not, section 1.1 ("Installation") was merely skimmed or even skipped if the user was able to obtain Rust and Cargo from the system package manager (e.g., 'apt-get -u install rustc cargo').

Section 1.2 ("Hello, World!") does a good job of bootstrapping the developer on the base-level essentials by creating a source artifact by hand and compiling it with rustc. The prose talks about a "project", which from context means something like "some programming endeavor"; it is clearly not some IDE-specific term, though such tools often use the term "project" for a tool-specific concept. Other familiar terminology used in this section includes "directory", "source file", "program", and "function" (in particular, "main function").

Though it could be said that the user has compiled a binary crate, that terminology is not yet introduced. It is instead referred to only as a "program" and a "binary executable", terms familiar to the reader, without any ambiguity or loss of meaning. All good.

Section 1.3 ("Hello, Cargo!") does a good job of mapping the manually created artifacts into the conventional structure expected by Cargo and achieving the same results as the earlier steps that used rustc directly. Nice.

It also mentions the familiar term "libraries", and that the Cargo-specific term "dependencies" means (apparently) the same thing thing that it means in casual developer-to-developer conversation. No surprises there; good.

Section 1.3 does a good job of motivating the need for a tool like Cargo to manage dependencies and to make build commands the same across projects (cargo build, cargo run, etc.).

Note that 1.3 is (appropriately, IMO) still using the generic term "project". The term "package" is mentioned only in passing, and reader gets the impression that it has something to do with specifying the metadata (name, version, etc) of a project.

The "Creating a Project with Cargo" section contains the first example the user sees of the cargo new command, and the section title says that the thing being created is a "project" (not a "package").

So far, so good.

1.3 notes that the rest of the book assumes the use of Cargo, and the section ends by pointing the reader at The Cargo Book to learn more.

So the developer decides to get more comfortable with Cargo before proceeding with the rest of The Book, and heads on over to The Cargo Book.

So now the user is looking at the beginning of The Cargo Book:

    Introduction
    1. Getting Started

        1.1. Installation
        1.2. First Steps with Cargo

    2. Cargo Guide
    ...

The "Introduction" page introduces the common term "package manager", and describes what that means more specifically for Cargo. This statement keeps the user comfortable in the knowledge that experience with other language-specific package managers seems to have an analogue in the Rust ecosystem.

The "Introduction" mentions that the "Getting Started" chapter will "set up your first crate". This is the first time the user has seen the term "crate". Aside from that one mention, however, the word "crate" is not used anywhere else in the "Getting Started" chapter.

The "Introduction" also mentions that the "Cargo Guide" chapter "will give you all you need to know about how to use Cargo to develop Rust packages". This is the second time the user is seeing the term "package", but it has not yet been defined. The user may have a rough notion about its meaning, as mentioned above.

If the user peeks ahead at the first two sections of the "Cargo Guide" chapter, the word "package" is used as if the user already knows what it is. So the user thinks, "Alright, it must be defined somewhere between the Introduction and here", and goes back to the Introduction.

The curious (or skeptical) reader would be well served by peeking ahead at the glossary at this point, but may think that is "too into the weeds" at this stage. In any event, it doesn't happen.

From this point forward, the scenario is the same as noted in the "Motivation" section of the description of issue #8854, so I'll just quote it here (with the obsolete bits struck):

Motivation

The current reading sequence is as follows:

  1. The "Introduction" mentions that Cargo is Rust's "package manager", and
    that it manipulates "packages" (whatever those are).

  2. The "Getting Started" index urges the user to install Cargo (and Rust)
    and to set up the user's first crate (whatever that is).

  3. The "Getting Started"/"Installation" page gets the use squared away with
    tools installation.

  4. The "Getting Started"/"First Steps with Cargo" page then dives into
    instructing the user to "start a new package with Cargo".

Up until this point, the user has not been told what a "package" or a "crate"
is. A new user just poking around Rust might wonder, "What is a package, and
why would I want one? And what does a crate have to do with it?"

The terms in the above list are all well defined elsewhere in the Rust and
Cargo documentation, but a new user encountering them for the first time
should not need to hunt them down.

Since the opening sections of the Cargo book are among the first documents a
new user is likely to encounter, it would be nice to provide a little
cheatsheet at this stage of the essentials. Defining the words in the above
list would give the reader a good foothold to map concepts they may be
familiar with from other languages onto their Rust counterparts (roughly
speaking).

In general, if the prose within the sections in the "Introduction", the "Getting Started" chapter, and the "Cargo Guide" chapter were to provide links into the glossary upon the first mention of a given terms on a given section page, that would both answer the user's question about what a given term means and also inform the user that "Hey, there's this great list of definitions over here (that you may have otherwise missed)". Such links would also avoid the user needing to go hunt down the terms manually. Instead of providing a new cheatsheet in the form of an "Essential Terminology" page (as this original PR did), we would be pointing the user to the existing list of definitions (no cheatsheet needed).

@salewski salewski marked this pull request as draft November 16, 2020 21:31
@salewski salewski force-pushed the ads/issue-8854-doc-essential-terms branch 2 times, most recently from aaa87d6 to 5a299bf Compare November 21, 2020 20:21
Add a handful of entries to the glossary of The Cargo Book, and add
intra-glossary hyperlinks for terms. A full catalog of the specific
changes follows.

Glossary entries added:

    + 'Cargo.lock' -- just points to the 'lock file' entry

    + 'Cargo.toml' -- just points to the 'manifest' entry

    + 'Module' -- explained in relation to 'crate'

    + 'Package manager' -- first term in the Introduction

    + 'Package registry' -- Another term from the Introduction. This
       entry just points to the 'registry' entry

Glossary entries modified:

    + 'Artifact'
        - Extend def. to include generated docs.

    + 'Crate'
        - Refer to a "Rust crate" as a hint that it is a term that
          exists outside of Cargo.

        - Refer to a "Cargo package" (rather than just "package") to
          reflect the fact that the term is a concept introduced by
          Cargo (as opposed to being inherent to Rust).

        - Link to related terms: 'module', 'package', 'registry',
          and 'target'.

    + 'Edition'
        - Link to related term: 'manifest'.

    + 'Feature'
        - Link to related term: 'manifest'.

    + 'Index'
        - Markdown: add emphasis to first mention of term "index".
        - Link to related terms: 'crate', 'registry'.

    + 'Lock file'
        - Link to related terms: 'package', 'workspace'.

    + 'Manifest'
        - Link to related terms: 'package', 'workspace'.

    + 'Member'
        - Link to related terms: 'package', 'workspace'.

    + 'Package'
        - Note that every target is a crate, and that the type
          (library or binary) is determined by the Cargo.toml file.

        - Note relationship to workspaces.

        - For "package root", add "compare to" note referencing
          "workspace root".

        - Link to related terms: 'crate', 'manifest', 'target',
          'workspace'.

    + 'Registry'
        - Link to related terms: 'crate', 'index', 'package'.

    + 'Source'
        - Link to related terms: 'crate', 'package'.

    + 'Target'
        - Link to related terms: 'artifact', 'manifest', 'package',
          'workspace'.

    + 'Test Targets'
        - Link to related terms: 'crate', 'manifest'.

    + 'Workspace'
        - For "workspace root", add "compare to" note referencing
          "package root".

        - Link to related terms: 'lock file', 'manifest', 'member',
          'package'.
No language changes; just make these existing terms link to their
corresponding entries in the glossary:
   - crate
   - package
   - package manager
   - package registry
@salewski salewski force-pushed the ads/issue-8854-doc-essential-terms branch from 5a299bf to c69618e Compare November 21, 2020 20:58
In the "First Steps with Cargo" section, add a short introductory
paragraph informing the reader what to expect from the page.

This provides a transition for the reader who may not yet know what
a package is. Rather than jump right into "To start a new package
with Cargo, ...", we now set the context for the purpose of the
page, and also provide hyperlinks into our Glossary for the terms
'package', 'manifest', and 'crate'.
The "Why Cargo Exists" section of the "Cargo Guide" is here split
into two subsections:

    "Preliminaries"
    "Enter: Cargo"

The content in "Preliminaries" is new, and provides a transition
that motivates the need for a package manager rather than using
'rustc' directly. It provides footing for the reader that knows very
little about Rust and nothing about Cargo.

The "Enter: Cargo" subsection contains the previous content,
augmented with a new paragraph explaining how the conventional list
of build targets simplifies working with Cargo packages: "...once
you know how to build one Cargo-based project, you know how to build
/all/ of them."

The following terms are linked to their Glossary entries:
    - artifact
    - crate
    - package
    - package manager
    - registry
…lossary

The following terms are linked to their Glossary entries:
    - crate
    - manifest
    - package

Also note that the generated "hello world" program is known as a
"binary crate".
…ossary

The following term(s) are linked to their Glossary entries:
    - package
The following term(s) are linked to their Glossary entries:
    - crate
    - package
    - package registry
…sary

The following term(s) are linked to their Glossary entries:
    - module
    - package
…ossary

The following term(s) are linked to their Glossary entries:
    - manifest
    - package
The following term(s) are linked to their Glossary entries:
    - package
… to glossary

The following term(s) are linked to their Glossary entries:
    - package
The following term(s) are linked to their Glossary entries:
    - crate
    - package
    - registry
The following term(s) are linked to their Glossary entries:
    - workspace
@salewski salewski force-pushed the ads/issue-8854-doc-essential-terms branch from c69618e to ab78221 Compare November 21, 2020 21:13
@salewski
Copy link
Contributor Author

I've reworked this PR as described in my last comment and the newly updated PR description; please take a look when you can:

  • The bolted-on "Essential Terminology" section is no longer present, and the information from it incorporated into the Glossary.
  • The Glossary itself has been updated to link intra-glossary terms with one another. (Hopping around via the links is sometimes more effective than scrolling around.)
  • The terms mentioned in the "Introduction" are now links into the Glossary.
  • The "Getting Started" -> "First Steps with Cargo" section has a new into blurblet that tells the reader what to expect from that page. Though the reader may not be familiar with the terms used, the links from them into the Glossary allow quick lookup.
  • The "Cargo Guide" -> "Why Cargo Exists" page explains why building with a package manager is better than without. It answers the question, "Why should I care about Cargo when I've got rustc(1) and make(1)?" It also bridges the realm of familiar terms the user can be assumed to know ("libary", "program", (maybe) "rustc", (less so) "crate") to concepts important in the realm of Cargo ("crate", "package", "package manager", "registry").
  • Throughout the first two chapters ("Getting Started" and "Cargo Guide"), the first time a term is used within a section it is a link into the Glossary. The first time a term is used within a chapter the link uses markdown for italics (consistent with how italics was previously used when introducing new terms).

The idea with the last item is that new users that have already read through the "Cargo Guide" are likely to be coming back to it for reference as they work with Rust. The links into the Glossary make it easier to jump into a certain section and remind oneself of what a given term means. It also serves as a reminder that the Glossary exists, which is a nice reminder that good definitions can be had from something more authoritative than a random web search.

Any feedback much appreciated. I'm happy to rework this based on suggestions for improvements. Am also fine with just dropping it if this kind of thing just isn't wanted; just let me know. Thanks,
-Al

@salewski salewski marked this pull request as ready for review November 21, 2020 22:35
Copy link
Contributor

@ehuss ehuss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me. @alexcrichton did you have any concerns?

@alexcrichton
Copy link
Member

Sorry for taking a bit long to get back to you @salewski, but everything you're mentioning and the changes here look great to me! Thanks so much for giving the docs some love, it's always very much appreciated :)

@bors: r+

@bors
Copy link
Contributor

bors commented Nov 25, 2020

📌 Commit ab78221 has been approved by alexcrichton

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 25, 2020
@bors
Copy link
Contributor

bors commented Nov 25, 2020

⌛ Testing commit ab78221 with merge 9991af3...

@bors
Copy link
Contributor

bors commented Nov 25, 2020

☀️ Test successful - checks-actions
Approved by: alexcrichton
Pushing 9991af3 to master...

@bors bors merged commit 9991af3 into rust-lang:master Nov 25, 2020
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Dec 4, 2020
Update cargo

12 commits in bfca1cd22bf514d5f2b6c1089b0ded0ba7dfaa6e..63d0fe43449adcb316d34d98a982b597faca4178
2020-11-24 16:33:21 +0000 to 2020-12-02 01:44:30 +0000
- Add "--workspace" to update command (rust-lang/cargo#8725)
- Add an FAQ for "Why is my crate rebuilt?" (rust-lang/cargo#8927)
- Set docs.rs as the default extern-map for crates.io (rust-lang/cargo#8877)
- remove extra whitespace when running cargo -Z help (rust-lang/cargo#8924)
- Remove version from dev-dependencies to make it easier to publish. (rust-lang/cargo#8920)
- update dependency queue to consider cost for each node (rust-lang/cargo#8908)
- Fix some rustdoc warnings. (rust-lang/cargo#8911)
- Bump miow dependency to not invalidly assume memory layout (rust-lang/cargo#8909)
- Remove unnecessary trailing semicolons (rust-lang/cargo#8906)
- Fix custom_target_dependency test. (rust-lang/cargo#8907)
- fix: we don't ignore `version` for `git`/`path` deps now (rust-lang/cargo#8900)
- doc (book): add "Getting Started" subsection: "Essential Terminology" (rust-lang/cargo#8855)
@ehuss ehuss added this to the 1.50.0 milestone Feb 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

doc (book): knowledge of essential terminology is assumed
5 participants