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

APIView for Rust #9592

Draft
wants to merge 52 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
bb837fc
v1 simplest
HarshaNalluru Jan 6, 2025
72fb624
struct, trait details are missing
HarshaNalluru Jan 6, 2025
8ae1a72
outputs
HarshaNalluru Jan 6, 2025
e4b6514
fix finding the root
HarshaNalluru Jan 6, 2025
929fbd9
id type is string
HarshaNalluru Jan 6, 2025
0cf9de9
redundant check
HarshaNalluru Jan 6, 2025
e20f975
input folder and the trimmed down docs.api.json
HarshaNalluru Jan 7, 2025
64428f1
outputs folder and cleanup main
HarshaNalluru Jan 7, 2025
e10f154
starter code
HarshaNalluru Jan 7, 2025
8579358
readme update
HarshaNalluru Jan 7, 2025
34d6e76
Merge branch 'Azure:main' into harshan/rust-api-parser
HarshaNalluru Jan 7, 2025
965d9cb
split into multiple files
HarshaNalluru Jan 7, 2025
5581316
put in folders
HarshaNalluru Jan 7, 2025
02b6087
more refactor
HarshaNalluru Jan 7, 2025
795bc4f
readme
HarshaNalluru Jan 7, 2025
ce72365
docs
HarshaNalluru Jan 7, 2025
07a6f57
add schema
HarshaNalluru Jan 7, 2025
9dc0ff4
Update tools/apiview/parsers/rust-api-parser/clean-rust-doc-output/RE…
HarshaNalluru Jan 11, 2025
dc8d50f
generate according to JSON schema
HarshaNalluru Jan 11, 2025
d384d8d
Merge branch 'harshan/rust-api-parser' of https://github.com/HarshaNa…
HarshaNalluru Jan 11, 2025
ccfe347
return type Result<(), Box<dyn std::error::Error>>
HarshaNalluru Jan 15, 2025
daedff6
major commit containing the following
HarshaNalluru Jan 15, 2025
f3747d3
address feedback
HarshaNalluru Jan 16, 2025
c1a5bef
Update tools/apiview/parsers/rust-api-parser/README.md
HarshaNalluru Jan 16, 2025
9270651
Update tools/apiview/parsers/rust-api-parser/README.md
HarshaNalluru Jan 16, 2025
c67f1d6
delete clean-rustdoc-output project in favour of the tool in the rust…
HarshaNalluru Jan 23, 2025
cc8c540
Merge branch 'harshan/rust-api-parser' of https://github.com/HarshaNa…
HarshaNalluru Jan 23, 2025
fc120ea
Support struct field.
HarshaNalluru Jan 23, 2025
228e79b
fix jsonTypes and improve processStructField support
HarshaNalluru Jan 23, 2025
3a512b4
fix metadata
HarshaNalluru Jan 23, 2025
6fdc1ab
beautify items
HarshaNalluru Jan 24, 2025
2d186f0
"@azure-tools/rust-genapi" makeover
HarshaNalluru Jan 24, 2025
f388cb0
processImpl works for "docs", still needs updates for "azure_core"
HarshaNalluru Jan 25, 2025
d92a1ce
split nonTraitImpls and traitImpls
HarshaNalluru Jan 26, 2025
c426ede
constant is good
HarshaNalluru Jan 26, 2025
14d02c6
enum support
HarshaNalluru Jan 26, 2025
2f83e79
createDocsReviewLine
HarshaNalluru Jan 26, 2025
c64d83c
unused
HarshaNalluru Jan 26, 2025
671502b
add doc review line only if docs is not empty
HarshaNalluru Jan 27, 2025
dc7fe7a
readme updates
HarshaNalluru Feb 4, 2025
c31c58b
address feedback
HarshaNalluru Feb 4, 2025
25682b3
org changes
HarshaNalluru Feb 4, 2025
88504cc
#[automatically_derived]
HarshaNalluru Feb 4, 2025
df5e23d
fix lifetimes
HarshaNalluru Feb 4, 2025
406cdea
handle self
HarshaNalluru Feb 4, 2025
aab02cf
processUse and minor consistency
HarshaNalluru Feb 5, 2025
05889da
bug: no need to track processed items
HarshaNalluru Feb 5, 2025
42f9fe8
&self and type info
HarshaNalluru Feb 5, 2025
28e96f3
support glob pattern
HarshaNalluru Feb 6, 2025
8a7f89b
fix 'static
HarshaNalluru Feb 6, 2025
f35f756
format and update args
HarshaNalluru Feb 6, 2025
4dc351c
processAutoTraitImpls
HarshaNalluru Feb 6, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -517,4 +517,5 @@ tools/apiview/emitters/typespec-apiview/temp/

# Issue Labeler Deploy
tools/issue-labeler/src/IssueLabeler/Properties/*Zip Deploy.json
tools/issue-labeler/src/IssueLabeler/Properties/ServiceDependencies/
tools/issue-labeler/src/IssueLabeler/Properties/ServiceDependencies/
tools/apiview/parsers/js-api-parser/
4 changes: 4 additions & 0 deletions tools/apiview/parsers/rust-api-parser/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
inputs
node_modules
outputs
expected-outputs
9 changes: 9 additions & 0 deletions tools/apiview/parsers/rust-api-parser/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"arrowParens": "always",
"bracketSpacing": true,
"endOfLine": "lf",
"printWidth": 100,
"semi": true,
"singleQuote": false,
"tabWidth": 2
}
3 changes: 3 additions & 0 deletions tools/apiview/parsers/rust-api-parser/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# 1.0.0-beta.1

Marks the 1.0.0-beta.1 release of rust-api-parser.
24 changes: 24 additions & 0 deletions tools/apiview/parsers/rust-api-parser/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
## Rust SDK APIView Exporter
This TypeScript project reads a cleaned Rustdoc JSON file from the azure-sdk-for-rust repository and generates a new Rust API view capturing the exported API surface. This project organizes the API elements into modules, functions, and other Rust constructs. and preserves the parent-child hierarchy.

### Features
- Reads a Rustdoc JSON file (docs.rust.json).
- Extracts the exported API surface.
- Filters items to include only those with public visibility.
- Preserves the parent-child hierarchy.
- Writes the exported API surface to a JSON file based on the expected APIView JSON schema.

### Prerequisites
- Node.js and npm installed. You can install Node.js from nodejs.org.

## Usage
- `npm install`
- `npm run-script build`

### Run the project:
- `node ./dist/main.js {input_file_path} {output_file_path}`
- Example: `node ./dist/main.js /workspaces/azure-sdk-tools/tools/apiview/parsers/rust-api-parser/inputs/azure_core.rust.json /workspaces/azure-sdk-tools/tools/apiview/parsers/rust-api-parser/outputs/azure_core.json`
- Or if you have the package installed, you can run `rust-genapi <input_file_path> <output_file_path>`.

### License
This project is licensed under the MIT License. See the LICENSE file for details.
113 changes: 113 additions & 0 deletions tools/apiview/parsers/rust-api-parser/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file.
trigger:
branches:
include:
- main
- feature/*
- release/*
- hotfix/*
paths:
include:
- tools/apiview/parsers/rust-api-parser

pr:
branches:
include:
- main
- feature/*
- release/*
- hotfix/*
paths:
include:
- tools/apiview/parsers/rust-api-parser

extends:
template: /eng/pipelines/templates/stages/1es-redirect.yml
parameters:
stages:
- stage: 'Build'
variables:
- template: /eng/pipelines/templates/variables/image.yml
- name: NodeVersion
value: '18.x'
- name: ArtifactName
value: 'apiview'
- name: RustGeneratorDirectory
value: 'tools/apiview/parsers/rust-api-parser'
jobs:
- job: 'Build'

pool:
name: $(LINUXNEXTPOOL)
image: $(LINUXNEXTVMIMAGE)
os: linux

steps:
- task: NodeTool@0
inputs:
versionSpec: '$(NodeVersion)'
displayName: 'Use NodeJS $(NodeVersion)'

- script: |
npm install -g [email protected]
displayName: "Install npm 8.16.0"

- script: |
npm install
workingDirectory: $(RustGeneratorDirectory)
displayName: "Install npm packages Rust generator"

- script: |
npm run-script build
workingDirectory: $(RustGeneratorDirectory)
displayName: "Build Rust generator"

- pwsh: |
npm pack $(RustGeneratorDirectory)
Copy-Item ./*.tgz $(Build.ArtifactStagingDirectory)
displayName: "Pack Rust generator"

- task: 1ES.PublishPipelineArtifact@1
inputs:
targetPath: '$(Build.ArtifactStagingDirectory)'
artifactName: $(ArtifactName)

- ${{if and(eq(variables['Build.Reason'], 'Manual'), eq(variables['System.TeamProject'], 'internal'))}}:
- stage: 'Release'
dependsOn: Build
condition: Succeeded()
variables:
- template: /eng/pipelines/templates/variables/image.yml
- name: ArtifactName
value: 'apiview'
- name: FeedRegistry
value: 'https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-rust/npm/registry/'
jobs:
- job: PublishPackage
displayName: 'Publish rust-genapi package to devops feed'
pool:
name: $(LINUXNEXTPOOL)
image: $(LINUXNEXTVMIMAGE)
os: linux
steps:
- checkout: none
- download: current

- pwsh: |
$detectedPackageName=Get-ChildItem $(Pipeline.Workspace)/$(ArtifactName)/*.tgz
Write-Host "Detected package name: $detectedPackageName"
$registry="$(FeedRegistry)"
$regAuth=$registry.replace("https:","")
$npmReg = $regAuth.replace("registry/","");
$env:NPM_TOKEN="$(azure-sdk-devops-npm-token)"
Write-Host "Publishing to $($regAuth)"
npm config set $regAuth`:username=azure-sdk
npm config set $regAuth`:_password=`$`{NPM_TOKEN`}
npm config set $regAuth`:email=not_set
npm config set $npmReg`:username=azure-sdk
npm config set $npmReg`:_password=`$`{NPM_TOKEN`}
npm config set $npmReg`:email=not_set
Write-Host "Publishing package"
Write-Host "npm publish $detectedPackageName --registry=$registry --always-auth=true"
npm publish $detectedPackageName --registry=$registry --always-auth=true
displayName: Publish package
10 changes: 10 additions & 0 deletions tools/apiview/parsers/rust-api-parser/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// @ts-check

import eslint from "@eslint/js";
import tsEslint from "typescript-eslint";

export default tsEslint.config(
{ ignores: ["bin", "dist"] },
eslint.configs.recommended,
...tsEslint.configs.recommended,
);
Loading