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

Implement properties around participation in public APIs on importable paths and items. #260

Merged
merged 5 commits into from
Nov 7, 2023

Conversation

davidhewitt
Copy link
Contributor

Related to obi1kenobi/cargo-semver-checks#120

Adds new properties to ImportablePath to probe whether an API is "public", which is currently implemented as:

  • Has an importable path
  • Which may be deprecated
  • If not deprecated, it must not be hidden

This was done together in collaboration with @obi1kenobi (thanks, was fun pairing!); one or both of us may pick this up again in the future time permitting. Mostly complete barring the TODOs in edges.rs and indexed_crate.rs, plus test output will change once those are corrected.

@obi1kenobi obi1kenobi changed the base branch from rustdoc-v26 to rustdoc-v27 November 6, 2023 20:55
@obi1kenobi
Copy link
Owner

Summary of changes:

  • Rebased to point to rustdoc-v27 since that's currently the main branch of trustfall-rustdoc-adapter. My automation always backports from the latest version's branch to older versions.
  • Propagated #[doc(hidden)] and deprecation info through the visibility tracking and indexing code. This resolves a few of the previously-outstanding TODOs marked in the code.
  • Made the ImportablePath vertex variant hold an Rc for cheaper vertex cloning. This parallels the existing vertex variants' implementations.
  • Added doc_hidden, deprecated, and public_api_eligible properties to the Item type. The first two have obvious implementations, the last one is similar to the one for ImportablePath but includes a visibility check (pub or default visibility, like enum variants) as well. This is necessary to properly handle cases like:
pub struct Example {
    #[doc(hidden)]
    pub not_actually_public_api: i64,
}

That case requires this new public_api_eligible field because struct fields are not importable themselves (one can't use Example::not_actually_public_api) which means they don't have access to a public_api property via ImportablePath. The way I intend to implement the check here is by saying "the contained field is eligible to be public API, and since its parent struct is public API, the field itself is public API as well."

@obi1kenobi obi1kenobi marked this pull request as ready for review November 7, 2023 05:17
@obi1kenobi obi1kenobi changed the title implement notion of 'public_api' for importable paths Implement properties around public API participation on importable paths and items. Nov 7, 2023
@obi1kenobi obi1kenobi changed the title Implement properties around public API participation on importable paths and items. Implement properties around participation in public APIs on importable paths and items. Nov 7, 2023
@obi1kenobi obi1kenobi merged commit be510b0 into obi1kenobi:rustdoc-v27 Nov 7, 2023
obi1kenobi added a commit that referenced this pull request Nov 7, 2023
…e paths and items. (#260)

* implement notion of 'public_api' for importable paths

* Propagate deprecation and doc(hidden) info through visibility tracking.

* Rc the ImportablePath inside the vertex enum.

* Add public API eligibility on items for nested items' API visibility.

* Add test coverage for enum variants and trait associated items.

---------

Co-authored-by: Predrag Gruevski <[email protected]>
obi1kenobi added a commit that referenced this pull request Nov 7, 2023
…e paths and items. (#260)

* implement notion of 'public_api' for importable paths

* Propagate deprecation and doc(hidden) info through visibility tracking.

* Rc the ImportablePath inside the vertex enum.

* Add public API eligibility on items for nested items' API visibility.

* Add test coverage for enum variants and trait associated items.

---------

Co-authored-by: Predrag Gruevski <[email protected]>
obi1kenobi added a commit that referenced this pull request Nov 7, 2023
…e paths and items. (#260) (#298)

* Implement properties around participation in public APIs on importable paths and items. (#260)

* implement notion of 'public_api' for importable paths

* Propagate deprecation and doc(hidden) info through visibility tracking.

* Rc the ImportablePath inside the vertex enum.

* Add public API eligibility on items for nested items' API visibility.

* Add test coverage for enum variants and trait associated items.

---------

Co-authored-by: Predrag Gruevski <[email protected]>

* Skip `importable_paths` test on Rust versions prior to 1.73.

---------

Co-authored-by: David Hewitt <[email protected]>
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.

2 participants