Skip to content

[rust-api-parser] Update parser to have Stable Line IDs#10535

Merged
HarshaNalluru merged 9 commits intoAzure:mainfrom
HarshaNalluru:harshan/rust-stable-line-ids
May 5, 2025
Merged

[rust-api-parser] Update parser to have Stable Line IDs#10535
HarshaNalluru merged 9 commits intoAzure:mainfrom
HarshaNalluru:harshan/rust-stable-line-ids

Conversation

@HarshaNalluru
Copy link
Copy Markdown
Contributor

@HarshaNalluru HarshaNalluru commented May 5, 2025

Enhance Rust API Parser with Stable Line IDs

  • Introduced lineIdMap to map item IDs to stable, meaningful identifiers rather than relying on the dynamic rustdoc ids.
  • Updated updateReviewLinesWithStableLineIds to ensure consistent review line IDs across modules and external references.
  • Preserved the linking between items in the api view rendering
  • This is required to show meaningful diff between api views
  • Other changes include formatting and minor refactoring

New diff

  • azure_identity
    image
  • azure_core
    image
  • azure_messaging_eventhubs
    image
  • azure_security_keyvault_certificates
    image

* formattign changes and "use name = summary" pattern

* replaceCratePath utils

* split if glob for "use"

* checkpoint - do not show internal details such as generated::*

* external module reexports being handled better

* formatting changes and upgrade version

* refactor common logic - re-export refs

* processExternalReferences

* linedid utils

* checkpoint with a bug

* new strategy to isolate the Use items - draft

* simple Use item - id fix

* template looks great

* addExternalReferencesIfNotExists improvement

* added a case where use item has not been processed yet, so we process it.

* parent info missed

* format

* bug fix for identity

* generic args fix

* registerExternalItemReference

* changelog

* collapse rootModule into top-level

* replaceSuperPrefix

* line id utils added

* update function name

* stable lineIds updates
Copilot AI review requested due to automatic review settings May 5, 2025 12:54
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR updates the Rust API parser to support stable line IDs by introducing a persistent mapping via lineIdMap and updating all relevant processing functions accordingly. Key changes include:

  • Introducing and integrating the new lineIdMap into item processing functions.
  • Updating functions such as registerExternalItemReference, processUse, and various process* functions to use consistent line IDs.
  • Minor refactorings and formatting improvements to support the new stable line IDs.

Reviewed Changes

Copilot reviewed 23 out of 23 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tools/apiview/parsers/rust-api-parser/src/process-items/utils/externalReexports.ts Updated to use lineIdMap and stable line IDs for external re-exports.
tools/apiview/parsers/rust-api-parser/src/process-items/processUse.ts Adjusted processing to include stable line ID mapping and update children accordingly.
tools/apiview/parsers/rust-api-parser/src/process-items/processUnion.ts Integrated lineIdMap for union items.
tools/apiview/parsers/rust-api-parser/src/process-items/processTypeAlias.ts Added lineIdMap usage for type aliases.
tools/apiview/parsers/rust-api-parser/src/process-items/processTraitAlias.ts Enabled stable line IDs via lineIdMap for trait aliases.
tools/apiview/parsers/rust-api-parser/src/process-items/processTrait.ts Updated to set stable line IDs for trait items.
tools/apiview/parsers/rust-api-parser/src/process-items/processStructField.ts Enhanced field processing with stable line IDs through lineIdMap.
tools/apiview/parsers/rust-api-parser/src/process-items/processStruct.ts Modified struct processing to incorporate the new line ID mapping.
tools/apiview/parsers/rust-api-parser/src/process-items/processStatic.ts Updated static item processing with stable line IDs.
tools/apiview/parsers/rust-api-parser/src/process-items/processProcMacro.ts Integrated lineIdMap usage for procedural macros and added related line IDs.
tools/apiview/parsers/rust-api-parser/src/process-items/processModule.ts Incorporated stable line IDs in module processing and re-exports.
tools/apiview/parsers/rust-api-parser/src/process-items/processMacro.ts Adjusted macro processing for stable line ID tracking.
tools/apiview/parsers/rust-api-parser/src/process-items/processImpl.ts Updated implementation processing to append stable suffixes using lineIdMap.
tools/apiview/parsers/rust-api-parser/src/process-items/processFunction.ts Now sets stable line IDs for function items.
tools/apiview/parsers/rust-api-parser/src/process-items/processExternType.ts Added stable line ID mapping for extern types.
tools/apiview/parsers/rust-api-parser/src/process-items/processEnum.ts Updated enum processing to integrate stable line IDs with minor refactoring.
tools/apiview/parsers/rust-api-parser/src/process-items/processConstant.ts Enhanced constant items to use stable line IDs.
tools/apiview/parsers/rust-api-parser/src/process-items/processAssocType.ts Introduced stable line ID mapping for associated types.
tools/apiview/parsers/rust-api-parser/src/process-items/processAssocConst.ts Updated associated constants processing with stable line IDs.
tools/apiview/parsers/rust-api-parser/src/main.ts Updated codeFile building to include an update to stable line IDs on review lines.
Comments suppressed due to low confidence (1)

tools/apiview/parsers/rust-api-parser/src/process-items/processMacro.ts:21

  • [nitpick] The variable 'linedId' is inconsistent with the naming convention used elsewhere (e.g. 'lineId'). Consider renaming it to 'lineId' for consistency across the codebase.
const linedId = item.id.toString();

Comment thread tools/apiview/parsers/rust-api-parser/src/process-items/processEnum.ts Outdated
Comment thread tools/apiview/parsers/rust-api-parser/CHANGELOG.md Outdated
Copy link
Copy Markdown
Member

@heaths heaths left a comment

Choose a reason for hiding this comment

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

A couple of questions/nits, but I see nothing blocking.

Comment thread tools/apiview/parsers/rust-api-parser/CHANGELOG.md Outdated
Comment thread tools/apiview/parsers/rust-api-parser/src/process-items/processModule.ts Outdated
Comment thread tools/apiview/parsers/rust-api-parser/src/utils/lineIdUtils.ts
@HarshaNalluru HarshaNalluru merged commit ee1bd4d into Azure:main May 5, 2025
7 checks passed
JoshLove-msft pushed a commit to JoshLove-msft/azure-sdk-tools that referenced this pull request May 29, 2025
* Enhance Rust API Parser with Stable Line IDs (Azure#1)

* formattign changes and "use name = summary" pattern

* replaceCratePath utils

* split if glob for "use"

* checkpoint - do not show internal details such as generated::*

* external module reexports being handled better

* formatting changes and upgrade version

* refactor common logic - re-export refs

* processExternalReferences

* linedid utils

* checkpoint with a bug

* new strategy to isolate the Use items - draft

* simple Use item - id fix

* template looks great

* addExternalReferencesIfNotExists improvement

* added a case where use item has not been processed yet, so we process it.

* parent info missed

* format

* bug fix for identity

* generic args fix

* registerExternalItemReference

* changelog

* collapse rootModule into top-level

* replaceSuperPrefix

* line id utils added

* update function name

* stable lineIds updates

* Update tools/apiview/parsers/rust-api-parser/src/process-items/processEnum.ts

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* changelog

* Update tools/apiview/parsers/rust-api-parser/CHANGELOG.md

* Update tools/apiview/parsers/rust-api-parser/CHANGELOG.md

* more descriptive unknown_names - the codepath that doesn't get hit

* type

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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.

4 participants