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

Support for cargo workspaces #8

Closed
U007D opened this issue Sep 6, 2017 · 6 comments
Closed

Support for cargo workspaces #8

U007D opened this issue Sep 6, 2017 · 6 comments

Comments

@U007D
Copy link

U007D commented Sep 6, 2017

I have a project making use of a cargo workspace, but only the main crate is revealed when I issue a cargo modules command.

Great tool, thank you!

@regexident
Copy link
Owner

I have a project making use of a cargo workspace, but only the main crate is revealed when I issue a cargo modules command.

Very good point. I haven't had a need for workspaces myself yet, thus didn't think of it when building cargo modules.

How would you expect the output to look? Something like this?

foo : crate
├── bar : public
╎   └── tests : private @ #[cfg(test)]
╎
└── baz : crate
    └── blee : public
        └── tests : private @ #[cfg(test)]

It might further more make sense to switch from public/private to pub mod/mod, as now crates can appear deeply nested within the tree (sub-crate of sub-crate of …). 🤔

foo : crate
├── bar : pub mod
╎   └── tests : mod @ #[cfg(test)]
╎
└── baz : crate
    └── blee : pub mod
        └── tests : mod @ #[cfg(test)]

While public/private is nicer on the eyes pub mod/mod is a better fit for Rust's own semantics/keywords.

Further more I would probably want to keep this feature behind a --workspace option, so that one can still choose to only print the root crate's modules.

Great tool, thank you!

Glad you like it!

@hongxuchen
Copy link

I have a project which contains several crates. Rather than providing one single crate modules info, running cargo modules in the project root directory emits an error:

Error: Failed to parse JSON response.
UnexpectedEndOfJson

But it works fine when using it inside each crate.

@U007D
Copy link
Author

U007D commented Dec 29, 2017

@regexident Sorry, somehow I missed your initial reply.

Yes, the output you outlined with the (Rust-specific visibility) syntax looks good to me.

@regexident
Copy link
Owner

@U007D no worries.

I’m somewhat busy right now but will tackle this as soon as I find some spare time. :)

hmvp pushed a commit that referenced this issue Jun 8, 2019
…ated)

This also gives us some workspace support (you need to choose a target from workspace)
Improves #8 but only by not crashing on workspaces. We still show one target.

The current assumption of one lib max fails when running in a workspace.
Since the current code does not allow to select a specific lib target

Also there are more target kinds than bin and lib that might be interesting to parse.

We should revist the user experience here or always show the whole workspace.
hmvp pushed a commit that referenced this issue Jun 15, 2019
…ated)

This also gives us some workspace support (you need to choose a target from workspace)
Improves #8 but only by not crashing on workspaces. We still show one target.

The current assumption of one lib max fails when running in a workspace.
Since the current code does not allow to select a specific lib target

Also there are more target kinds than bin and lib that might be interesting to parse.

We should revist the user experience here or always show the whole workspace.
@kvark
Copy link
Contributor

kvark commented May 5, 2020

More then 2 years passed, wow!
This is very much needed. All of the non-trivial projecs use workspaces these days.
For example, running it within any folder in https://github.com/servo/webrender gives me:

direct-composition : crate
 ├── com : private
 └── egl : private

... which is of no use, because the direct-composition crate is one I'm least interested in. I'll try to work around this, but having proper support would be valuable! To clarify, I don't have a strong idea whether you need to analyze the workspace as a whole (that would step into cargo-deps territory to some extent). Having it on a single crate would be good enough for us today.

@regexident how is your situation looking now? Would you be able to

@regexident regexident changed the title cargo workspace support request Support for cargo workspaces Dec 5, 2020
@regexident
Copy link
Owner

This should now be fixed with #66 having been merged. 🎉 😃
(The release still needs a it more work. If you're feeling lucky you can install from source and give it a try, though.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants