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

WIP: get rig of pub doc(hidden) #1736

Merged
merged 1 commit into from
Apr 11, 2020
Merged

WIP: get rig of pub doc(hidden) #1736

merged 1 commit into from
Apr 11, 2020

Conversation

CreepySkeleton
Copy link
Contributor

That is my attempt of removing the pub #[doc(hidden)] blasphemy. It is not ready yet - far from being ready, in fact. I'm just publishing it to get some feedback from @TeXitoi and @pksunkara .

@pksunkara
Copy link
Member

You are mixing so many things here. I like some parts, some parts I want to discuss. I especially dislike the view parts. Can you separate them into different kinds of PRs?

@CreepySkeleton
Copy link
Contributor Author

The view parts are the core point, they serve as interpolation API. Everything else is build on top of them. Could you be more specific about want you like and what you don't?

src/build/app/mod.rs Outdated Show resolved Hide resolved
src/build/app/mod.rs Outdated Show resolved Hide resolved
src/build/app/mod.rs Outdated Show resolved Hide resolved
src/build/arg/settings.rs Outdated Show resolved Hide resolved
src/build/mod.rs Outdated Show resolved Hide resolved
@pksunkara
Copy link
Member

Basically, there are few things not related view but still related doc(hidden) here. Let's separate them out and get them merged. Then, we can discuss about view.

@CreepySkeleton
Copy link
Contributor Author

Most of those things are ought to be pub because they are needed by clap_derive. I already told you that the crates are heavily intermixed to the point they are essentially the same crate.

@pksunkara
Copy link
Member

The views are too much work and complexity for macros that are public just because they are needed in clap_generate. That is basically my opinion on this PR. Everything else looks good to me.

@CreepySkeleton
Copy link
Contributor Author

CreepySkeleton commented Mar 9, 2020

So, you think this huge amount of pub hidden is just because it's used in macros? If so, you're only partially right; in fact, to a very little extent.

Those are just the usages my eye picked upon a shallow glance, there are many more of those to go on apart from macros. If ou are really curious, quickly change App and Arg fields frompub to pub(crate), run cargo check, and you'll see the devil 😈.

My point is, you're underestimating how deeply these two crates are tangled together. It's not "just macros".

@pksunkara
Copy link
Member

I have given it a bit of thought. I understand that we need the views. But can we try to minimize the fields inside them so that we are only doing for the fields we need?

@CreepySkeleton
Copy link
Contributor Author

minimize the fields inside them

Of course. As I stated, the work is a deep-in-progress. I've just copied the fields from App/Arg because the "everything at once" was simpler than figuring which specific fields I would need. The plan is to remove any excessive fields once it's done.

@CreepySkeleton
Copy link
Contributor Author

Also, what do you think about #810 (comment)?
That would be alternative to this PR.

@pksunkara
Copy link
Member

I would much prefer this PR than doing that. The reason we want clap_generate separate is that we want to give tools to the end users to write their own generators for their own weird things.

@CreepySkeleton
Copy link
Contributor Author

CreepySkeleton commented Mar 10, 2020 via email

@pksunkara
Copy link
Member

We should be able to solve that issue with macros. If they want those commands in their apps, they can use the macros. Or we can even provide a wrapper function in clap_generate. I think we can solve it without moving the generators into clap.

@pksunkara
Copy link
Member

Note for anyone looking, this needs a rebase on master since the above linked PR was created out of parts of this.

src/build/app/view.rs Outdated Show resolved Hide resolved
@pksunkara
Copy link
Member

pksunkara commented Apr 8, 2020 via email

@CreepySkeleton
Copy link
Contributor Author

What about creating AppBuilder and ArgBuilder structs to do the builder
pattern properly? The only downside of this all the chaining of args and
apps need to end with .build().

App and Arg are builders already. Are you suggesting to introduce a builder that builds a builder? [Yo dawg joke]

@CreepySkeleton CreepySkeleton force-pushed the right_visibility branch 2 times, most recently from 9278923 to 7da4883 Compare April 10, 2020 21:32
src/build/app/mod.rs Outdated Show resolved Hide resolved
src/build/arg/mod.rs Show resolved Hide resolved
src/build/arg/mod.rs Outdated Show resolved Hide resolved
src/build/app/mod.rs Show resolved Hide resolved
@CreepySkeleton
Copy link
Contributor Author

I'm positive that this was a spurious failure. My local test passes just fine and I haven't touched any code that could possible affect this. I'm flushing travis cache and restarting the build.

@CreepySkeleton
Copy link
Contributor Author

@pksunkara Do you want me to squash the commits into one?

@CreepySkeleton
Copy link
Contributor Author

Failure due to tarpalin is being unable to wait until ui tests have passed. I propose to exclude clap_derive from coverage, they don't count anyway.

Copy link
Member

@pksunkara pksunkara left a comment

Choose a reason for hiding this comment

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

Yes, please squash all the commits. Just have 2 minor comments. Once you fix them, I will merge this PR and you can create a new PR for the other doc(hidden) things.

src/build/app/mod.rs Show resolved Hide resolved
.args
.args
.iter()
.filter(|a| a.short.is_none() && a.long.is_none())
Copy link
Member

Choose a reason for hiding this comment

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

Should we add app.get_positionals()? This exact logic is being repeated in macro positionals! also. Would be nice to keep it DRY.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

get_positional borrows the whole app immutably, but we do app.settings.set() several lines below (mutable borrow.

Copy link
Member

@pksunkara pksunkara left a comment

Choose a reason for hiding this comment

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

bors r+

bors bot added a commit that referenced this pull request Apr 11, 2020
1736: WIP: get rig of pub doc(hidden) r=pksunkara a=CreepySkeleton



Co-authored-by: CreepySkeleton <creepy-skeleton@yandex.ru>
@bors
Copy link
Contributor

bors bot commented Apr 11, 2020

Build failed

@pksunkara
Copy link
Member

bors r+

@bors
Copy link
Contributor

bors bot commented Apr 11, 2020

@bors bors bot merged commit 874fbcf into master Apr 11, 2020
@bors bors bot deleted the right_visibility branch April 11, 2020 16:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Question: how to extract {flags, opts, subcommands, ...}
4 participants