Commit graph

290 commits

Author SHA1 Message Date
Ed Page
76bff6f34e fix!: Remove rest of deprecated APIs
Fixes #4009
2022-08-01 15:21:33 -05:00
Ed Page
8aa960c984 style: Make clippy happy 2022-07-28 15:11:28 -05:00
Ed Page
24735e3a1d fix!: Pull AppSettings out of API
Part of #3021
2022-07-22 16:05:54 -05:00
Ed Page
cf60f84894 fix!: Remove ArgSettings from the API 2022-07-21 16:17:44 -05:00
Ed Page
6e1e0f9fa2 fix!: Remove App alias for Command 2022-07-21 15:08:37 -05:00
Ed Page
cd9cbb4c20 fix!: Remove ArgMatches::*value* functions 2022-07-21 14:24:16 -05:00
Ed Page
ff0796b014 fix(derive)!: Remove old derive names 2022-07-21 12:57:12 -05:00
Ed Page
da5d5b8b53 fix!: Remove SubCommand 2022-07-21 12:48:52 -05:00
Ed Page
99d92c916c fix!: Remove yaml support 2022-07-21 12:46:47 -05:00
Ed Page
765af4198c fix!: Remove regex validation 2022-07-21 12:42:09 -05:00
Ed Page
5e02445ce5 docs: Small tweak to lib docs 2022-07-19 15:54:01 -05:00
Tshepang Mbambo
01d7e7ac04
docs: reduce the need to guess 2022-07-19 22:32:42 +02: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
Ed Page
7009ae63c8 doc: Explain why examples are missing
Fixes #3865
2022-06-30 08:29:16 -05:00
Stiopa Koltsov
464ef3920b refactor: Put once_cell reexport into __macro_refs
When upgrading our company projects from clap 3.1 to clap 3.2 I had
to fix several references to `clap::lazy_init`. People are not
supposed to do that, but that's hard to enforce.

Hope placing `once_cell` reexport into `__macro_refs` prevent at
least some of the such issues in the future.
2022-06-26 04:13:03 +01:00
Ed Page
7515bfeb51 fix: Allow people to opt-in to deprecations
This adds a new `Cargo.toml` feature named `deprecated` that opts
controls whether deprecation warnings show up.  This is starting off as
non-default though that may change (see below).

Benefits
- Allows a staged rollout so a smaller subset of users see new
  deprecations and can report their experience with them before everyone
  sees them.  For example, this reduces the number of people who have to
  deal with #3822.
- This allows people to defer responding to each new batch of
  deprecations and instead do it at once.  This means we should
  reconsider #3616.

The one risk is people who don't follow blog posts and guides having a
harder time upgrading to the next breaking release without the warnings
on by default.  For these users, we reserve the right to make the
`deprecated` feature `default`.  This is most likely to happen in a
minor release that is released in conjunction with the next major
release (e.g. when releasing 4.0.0, we release a 3.3.0 that enables
deprecations by default).  By using a feature, users can still disable
this if they want.

Thanks @joshtriplett for the idea
2022-06-14 10:50:05 -05:00
Ed Page
cb42df61e4 refactor: Switch to once_cell
Though this is changing an API item we export, we do not consider this a
breaking change because
- This was an implementation detail of the macros and people shouldn't be using it directly
- The `macro_rules` macro is coupled to `clap` because they are in the
  same crate
- The derive macro is coupled to `clap` because `clap` declares a
  `=x.y.z` dependency on `clap_derive

Fixes #3828
2022-06-14 09:10:50 -05:00
Ed Page
9e38353442 fix(derive): Clarify ArgEnum as ValueEnum
We aren't enumerating arguments but values for an argument, so the name
should reflect that.

This will be important as part of #1807 when we have more specific
attribute names.
2022-06-08 11:14:09 -05:00
Ed Page
52e2874c03 fix(builder): Make it easier to discover/access ArgAction 2022-06-04 12:58:53 -05:00
Ed Page
a712adefcd fix(parser): Deprecate value_of and friends 2022-05-25 12:57:11 -05:00
Ed Page
399c138825 fix: Soft-deprecate several items within the root 2022-05-12 06:18:08 -05:00
Ed Page
4fea1515b6 feat: Expose builder/parser modules
The top-level API for clap is getting a bit bloated.  By exposing these
modules, we'll be able to continue to add new, less commonly used types
while keeping the main API focused.
2022-05-12 06:17:08 -05:00
Ed Page
5ae9c75324 fix(clap): Allow disabling color with debug 2022-04-22 12:32:58 -05:00
Ed Page
b171802265 docs: Ensure IntoApp is visible 2022-02-15 11:16:22 -06:00
Ed Page
ddac492302 fix: Rename IntoApp to CommandFactory
This is part of the `App` rename.

Previously, I was concerned about not being able to deprecate

For backwards compatibility, we still expose the `IntoApp` name.
2022-02-15 08:24:00 -06:00
Ed Page
c4144d7d6c docs: Update App references to Command 2022-02-14 15:33:49 -06:00
Ed Page
524e164c31 fix: Rename App to Command 2022-02-14 15:32:07 -06:00
Ed Page
6c7126b156 docs: Hide items deprecated in 3.0.0
We left them in the docs for a period of time to help people find docs
for code that was still in use.  Balancing that with the need for clean
docs, it seems like 3.1 is an appropriate time to mark them hidden in
the docs.
2022-02-11 18:42:28 -06:00
Ed Page
60a8747603 refactor: Flatten directory heirarchy 2022-02-10 11:17:08 -06:00
Ed Page
edda56f072 feat(parser): Expose ValueSource
Fixes #1345
2022-02-08 15:05:51 -06:00
Ed Page
2d01331540 refactor(error): Prepare for splitting mod 2022-02-02 16:06:23 -06:00
Ed Page
5535f49d13 fix(error): Expose the error module
We'll be expanding whats included and we shouldn't spam the root as
much.
2022-02-02 15:35:20 -06:00
Ed Page
b55edfa740 refactor: Rename errors mod
It seems that `error` is more common (e.g. `nom`)
2022-02-02 15:34:17 -06:00
Ed Page
fa5daf4039
Merge pull request #3250 from epage/hyphen
fix(parser): Ignore Last when checking Hyphen Values
2022-01-04 09:46:59 -06:00
Daniel Eades
7f71d642cd style: prefer 'char' to 'str' for single character patterns 2022-01-04 09:20:08 -06:00
Ed Page
e6ee585a4b fix: Clarify short rejection in debug 2022-01-04 09:00:13 -06:00
Ed Page
895e85714b chore: Remove the TODO chaff
The intent is to make stand out more the important technical debt hidden
in comments.
2021-12-22 10:15:09 -06:00
Ed Page
d14255dc00 docs: Show features in docs.rs
Confirmed this works with [`argfile`](https://docs.rs/argfile/latest/argfile/)

And then running in clap
```
$ RUSTDOCFLAGS="--cfg docsrs" cargo +nightly doc --all-features
```
They now show up!
2021-12-16 10:38:31 -06:00
Janis Peukert
1f51e8cb2f docs: Clarify deprecation message for SubCommand
Only `SubCommand` is deprecated, not `Subcommand`.
This new deprecation message mentions this ambiguity.

Resolves #3147.
2021-12-11 14:47:08 -08:00
Ed Page
9d7becca68 docs: Update deprecation messages
- Some still referenced the clapng issue number
- Some YAML ones were missed in the formatting clean up
- I never updated the usage ones with the formatting clean up
2021-12-09 06:47:37 -06:00
Ed Page
d42cfee912 docs: Auto-tag feature flags
Fixes #3095
2021-12-08 20:37:53 -06:00
Ed Page
ffa5630de5 docs: Enable lib doc in more cases
Before, we limited it to the `doc` feature because of how extensive the
README was.  It has since scaled back, so we can be more selective with
what features enable it.
2021-12-08 20:37:50 -06:00
Ed Page
e98253dd4a fix: Rename 'doc' feature
This is prep for potentially other 'doc' changes
2021-12-08 20:10:47 -06:00
Ed Page
e5997c1001 docs: Clarify deprecations 2021-12-08 11:14:47 -06:00
Ed Page
093de2b83b docs: Add back in logo 2021-12-07 17:45:57 -06:00
Ed Page
c23f9230d1 chore: Remove stale boiletplate 2021-12-06 11:04:41 -06:00
Ed Page
8595357542 chore: Only error for warnings in CI
This makes it easier for developers to iterate, not having to stop to
write docs just to get things building.
2021-12-06 11:03:14 -06:00
Pavan Kumar Sunkara
cc2dddba8e Add DisableColoredHelp setting to improve flexibility (clap-rs/clap#2956)
Until we have a modular help generator that can be configured and/or
authored by the users themselves as part of #2914, we will provide the
flexibility of turning off colored help messages but still wanting
colored error messages.

This flexibility was available before #2845 and @dbrgn immediately
noticed it and requested it back to which I agree. This was also
suggested by Josh in
[here](https://github.com/clap-rs/clap/issues/2806#issuecomment-933877438)
2021-12-04 12:00:46 -06:00
Ed Page
500def4904 fix(derive): Smooth out transition for structopt
Adding in a `StructOpt` derive with `structopt` attributes, with
deprecation notices.  Unofrtunately, not as many deprecation warnings as
I would like.  Apparently, you can't do them for a `use` of a derive?  I
also wanted to inject code that would trigger a deprecation notice for
attributes but that would require enough of a refactor that I didn't
consider it worth it.  We are at least providing a transition window
even if it means we'll have to remvoe it next major release without a
deprecation warning.
2021-12-02 20:18:33 -06:00
Ed Page
d4173bd596 docs: Clean up deprecations 2021-11-23 10:32:05 -06:00