Commit graph

17 commits

Author SHA1 Message Date
Gilbert Gilb's
39cf3e7124
doc(fix typo): add missing "l" in "toml" 2022-10-01 20:36:01 +02:00
KuuWang
71be5463e5
doc(fix typo): no close bracket in example
Tutorials (derive, builder > Tutorials (derive, builder)
2022-09-30 17:43:23 +09:00
Ed Page
f925ca84b6 docs: Clarify how to use examples
When we restuctured the examples, we lost the notes on how they should
be structured, so this adds it back in.
2022-09-26 21:06:02 -05:00
Ed Page
d43f1dbf6f docs: Move everything to docs.rs
A couple of things happened when preparing to release 3.0
- We needed derive documentation
  - I had liked how serde handled theres
  - I had bad experiences finding things in structopt's documentation
- The examples were broken and we needed tests
- The examples seemed to follow a pattern of having tutorial content and
  cookbook content
- We had been getting bug reports from people looking at master and
  thinking they were looking at what is currently released
- We had gotten feedback to keep down the number of places that
  documentation was located

From this, we went with a mix of docs.rs and github
- We kept the number of content locations at 2 rather than 3 by not
  having an external site like serde
- We rewrote the examples into explicit tutorials and cookbooks to align
  with the 4 styles of documentation
- We could test our examples by running `console` code blocks with
  trycmd
- Documentation was versioned and the README pointed to the last release

This had downsides
- The tutorials didn't have the code inlined
- Users still had a hard time finding and navigating between the
  different forms of documentation
- In practice, we were less likely to cross-link between the different
  types of documentation

Moving to docs.rs would offer a lot of benefits, even if it is only
designed for Rust-reference documentation and isn't good for Rust derive
reference documentation, tutorials, cookbooks, etc.  The big problem was
keeping the examples tested to keep maintenance costs down.  Maybe its
just me but its easy to overlook
- You can pull documentation from a file using `#[doc = "path"]`
- Repeated doc attributes get concatenated rather than first or last
  writer winning

Remember these when specifically thinking about Rust documentation made
me realize that we could get everything into docs.rs.

When doing this
- Tutorial code got brought in as was one of the aims
- We needed to split the lib documentation and the README to have all of
  the linking work.  This allowed us to specialize them according to
  their rule (user vs contributor)
- We needed to avoid users getting caught up in making a decision
  between Derive and Builder APIs so we put the focus on the derive API
  with links to the FAQ to help users decide when to use one or the
  other.
- Improved cross-referencing between different parts of the
  documentation
- Limited inline comments were added to example code
  - Introductory example code intentionally does not have teaching
    comments in it as its meant to give a flavor or sense of things and
    not meant to teach on its own.

This is a first attempt.  There will be a lot of room for further
improvement.  Current know downsides:
- Content source is more split up for the tutorials

This hopefully addresses #3189
2022-07-19 13:30:38 -05:00
Yuri Astrakhan
3fd5e4bc33
fix cargo.toml link 2022-05-27 07:43:09 -04:00
Ed Page
ec4735a44e docs: Add REPL example
This is to help in cases like #3668 and #3673
2022-05-02 06:27:57 -05:00
Ed Page
5be61a199c docs(examples); Call out optional subcommands 2022-04-01 09:27:29 -05:00
Ed Page
db863de6c1 docs(examples): Show how to do default subcommands
While we don't have a built-in mechanism, its relatively easy to support
with the APIs we provide.

Inspired by #3566
2022-03-23 11:08:07 -05:00
Ed Page
a8ffebbab9 docs(examples): Generalize key-value example 2022-03-14 09:38:04 -05:00
Nils Homer
c13cd89ceb
Fix link to contributing 2022-02-22 20:36:54 -08:00
Ed Page
f7419ec3d2 docs(examples): Be explicit about example topics 2022-02-22 08:43:33 -06:00
Ed Page
aa270f6aca docs(examples): Add cargo subcommand example 2021-12-15 12:07:29 -06:00
Ed Page
03cb509d6c refactor(examples): Change naming style
This is to make room for a reasonable looking cargo plugin example.

I got lazy and didn't update the tutorials.
2021-12-15 11:12:18 -06:00
Hiroaki ITO
c2dc425784
docs: Fix the pacman-like interface example link 2021-12-11 22:22:09 +09:00
Ed Page
c99adcc6c9 docs: Add key-value derive example
This is carried over from the clap_derive examples.  Looking over the
other examples, I feel like they are covered by other examples or by the
derive reference.  We should call out deny missing docs though.
2021-12-07 19:01:55 -06:00
Ed Page
befee6667b docs: Re-work examples
This creates distinct tutorial examples from complex feature examples
(more how-tos).  Both sets are getting builder / derive versions (at
least the critical ones).
2021-11-30 21:33:52 -06:00
Ed Page
bfa02fd418 test: More thoroughly test examples
This ports our example testing over to [trycmd](https://docs.rs/) so
we can:
- More thoroughly test our examples
- Provide always-up-to-date example usage

The old way of testing automatically picked up examples.  This new way
requires we have a `.md` file that uses the example in some way.

Notes:
- Moved overall example description to the `.md` file
- I added cross-linking between related examples
- `14_groups` had a redundant paragraph (twice talked about "one and
  only one"
2021-11-23 13:13:41 -06:00