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

[Python APIView] tree token parser conversion #9146

Draft
wants to merge 65 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 58 commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
0072502
update apiview tree parser tspconfig
swathipil Oct 11, 2024
2e87d07
update package.json
swathipil Oct 11, 2024
22537c3
add usage decorator
swathipil Oct 14, 2024
9fc0900
add service decorator temporarily for codegen
swathipil Oct 14, 2024
55d57e9
update tspconfig
swathipil Oct 15, 2024
cfaf9ed
initial generated code
swathipil Oct 15, 2024
08ac017
add global review line token
swathipil Oct 16, 2024
b6f1267
add blank lines
swathipil Oct 17, 2024
9f7a441
fix function node
swathipil Oct 24, 2024
c77e808
handle multi and single lines
swathipil Oct 29, 2024
ea6df1f
indent multi-line params extra
swathipil Oct 29, 2024
16feeb4
merge main
swathipil Oct 29, 2024
62c5ea5
regen for has_prefix_space
swathipil Oct 29, 2024
983bfd7
add blank line after class
swathipil Oct 29, 2024
a6a41b2
fix spacing/newlines in class
swathipil Nov 7, 2024
872d509
make multi line args children
swathipil Nov 7, 2024
94b2c13
print key node item type
swathipil Nov 7, 2024
d2b1d27
add to create review line
swathipil Nov 12, 2024
0fd2384
add ReviewLines
swathipil Nov 12, 2024
410f978
fix multi-line methods output w/ ReviewLines
swathipil Nov 13, 2024
15c4817
add diagnostic
swathipil Nov 14, 2024
8c92b43
fix tests
swathipil Nov 14, 2024
1a2ef27
fix more class parsing tests
swathipil Nov 14, 2024
6ea7952
get functions tests passing
swathipil Nov 14, 2024
e52c6aa
fix more tests
swathipil Nov 15, 2024
9b0c711
fix all class tests
swathipil Nov 15, 2024
c5f778f
fix dataclass tests
swathipil Nov 15, 2024
b6bd7f1
[TEMP] remove extra punctuation from add type test
swathipil Nov 15, 2024
f085996
pass apiview through node constructors
swathipil Nov 15, 2024
85ad187
fix diagnostics test
swathipil Nov 15, 2024
40e15fe
add back multi line pylint error
swathipil Nov 15, 2024
fbd7b1a
fix metadata map test
swathipil Nov 15, 2024
e4bbdc9
remove to test txt
swathipil Nov 25, 2024
14433ed
add context end line and parser header
swathipil Dec 2, 2024
1377d43
add NavigateToId
swathipil Dec 6, 2024
f08e506
update tests with apiview
swathipil Dec 6, 2024
d7e23dc
add navigation display name
swathipil Dec 6, 2024
f8afd55
add context end and related to line tests
swathipil Dec 7, 2024
6f621c1
fix bug
swathipil Dec 10, 2024
6ec9b12
clean up TODOs
swathipil Dec 11, 2024
2304ae3
add render classes for nav icons
swathipil Dec 16, 2024
a3d27ce
update readme w/ info
swathipil Dec 16, 2024
0ed7427
re-gen from tsp
swathipil Dec 17, 2024
1cb61bd
run black
swathipil Dec 17, 2024
522cf67
black
swathipil Dec 17, 2024
7fca9f6
add tsp-location
swathipil Dec 17, 2024
0c47b42
Merge branch 'main' into swathipil/pyapi/add-py-tspconfig
swathipil Dec 17, 2024
63de880
rever apiview tsp to main, move all changes to separate pr
swathipil Dec 17, 2024
d8a6aa0
newline at end of package lock
swathipil Dec 17, 2024
29b9fb7
update version
swathipil Dec 17, 2024
c6033fe
[temp] print cwd for failing ci
swathipil Dec 17, 2024
84b6b90
add init to _generated + remove temp cwd printing
swathipil Dec 17, 2024
00a9c89
add isodate/typing-extensions to setup.py
swathipil Dec 17, 2024
2142d35
add azure-core to setup.py
swathipil Dec 17, 2024
67fd995
add external link token kind
swathipil Dec 17, 2024
cf22e8e
test source url
swathipil Dec 18, 2024
9bf821e
black
swathipil Dec 18, 2024
af7fa13
add is context end to class and remove from single line functions
swathipil Dec 18, 2024
d44874e
address comments
swathipil Dec 18, 2024
62c7cc1
update readme
swathipil Dec 18, 2024
bc0872c
update tspconfig commit
swathipil Jan 13, 2025
0232887
merge main
swathipil Jan 14, 2025
65e5476
travis comments, fix function special arg indent + remove lstrip from…
swathipil Jan 15, 2025
3857520
travis comments, update tests to count relatedToLine and isContextEnd…
swathipil Jan 16, 2025
f9a4a0a
add relatedline/endcontext count to more tests
swathipil Jan 16, 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
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
SomethingWithDecorators,
SomethingWithInheritedOverloads,
SomethingWithOverloads,
SomethingWithProperties
SomethingWithProperties,
SomeProtocolDecorator
)
from ._dataclasses import (
DataClassSimple,
Expand Down Expand Up @@ -64,5 +65,6 @@
"SomethingWithDecorators",
"SomethingWithInheritedOverloads",
"SomethingWithOverloads",
"SomethingWithProperties"
"SomethingWithProperties",
"SomeProtocolDecorator"
)
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
import datetime
from enum import Enum, EnumMeta
import functools
from typing import Any, overload, Dict, TypedDict, Union, Optional, Generic, TypeVar, NewType, ClassVar
from typing import Any, overload, Dict, TypedDict, Union, Optional, Generic, TypeVar, NewType, ClassVar, Protocol
from typing_extensions import runtime_checkable

from ._mixin import MixinWithOverloads

Expand Down Expand Up @@ -325,3 +326,7 @@ def empty(self) -> bool:
AliasUnion = NewType('AliasUnion', Union[str, int, bool])

AliasNewType = NewType('AliasNewType', Dict[str, str])

@runtime_checkable
class SomeProtocolDecorator(Protocol):
pass
3 changes: 3 additions & 0 deletions packages/python-packages/apiview-stub-generator/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Release History

## Version 0.3.13 (Unreleased)
swathipil marked this conversation as resolved.
Show resolved Hide resolved
Update for tree token style parser.

## Version 0.3.12 (2024-02-27)
Add support for Cross Language Package ID.

Expand Down
16 changes: 14 additions & 2 deletions packages/python-packages/apiview-stub-generator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ Following are the steps to create an API review request for python package.
### Generate stub File
`apiview-stub-generator` package is used to generate stub file tokens from either source code repo or from prebuilt wheel package. Following are the steps to generate stub file token.

Install `apiview-stub-generator` package. From the root of the apiview-stub-generator package, run:
Install `apiview-stub-generator` package on Python <=3.10. From the root of the apiview-stub-generator package, run:
```
pip install . --extra-index-url="https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-python/pypi/simple/"
(venv310) apiview-stub-generator> pip install . --extra-index-url="https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-python/pypi/simple/"
swathipil marked this conversation as resolved.
Show resolved Hide resolved
```

Run `apistubgen` command with source repo or whl package as parameter and this will generate a json file with tokens.
Expand All @@ -42,6 +42,18 @@ apistubgen --pkg-path C:\git\azure-sdk-for-python\sdk\core\azure-core --out-path

Token file will be created with a naming convention `<package-name>_python.json'

#### ApiStubGen options

The following options are available when running `apistubgen`:
```
```

### Running tests
```
apiview-stub-generator> pip install . --extra-index-url="https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-python/pypi/simple/"
apiview-stub-generator> pip install -r dev_requirements.txt
```


### Upload token file to API review portal
- Go to ``https://apiview.dev``
Expand Down
20 changes: 10 additions & 10 deletions packages/python-packages/apiview-stub-generator/apistub/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@

from ._version import VERSION
from ._stub_generator import StubGenerator
from ._token import Token
from ._token_kind import TokenKind
from ._apiview import ApiView, Navigation, NavigationTag, Kind
from ._diagnostic import Diagnostic, DiagnosticLevel
from ._generated.treestyle.parser.models import (
CodeDiagnostic as Diagnostic,
CodeDiagnosticLevel as DiagnosticLevel,
TokenKind,
ReviewToken as Token,
)
from ._generated.treestyle.parser.models._patch import ApiView, ReviewLine, ReviewLines

__version__ = VERSION

Expand All @@ -14,9 +17,8 @@
"Token",
"TokenKind",
"ApiView",
"Navigation",
"NavigationTag",
"Kind",
"ReviewLine",
"ReviewLines",
"Diagnostic",
"DiagnosticLevel",
]
Expand All @@ -31,8 +33,6 @@ def console_entry_point():
out_file_path = stub_generator.out_path
# Generate JSON file name if outpath doesn't have json file name
if not out_file_path.endswith(".json"):
out_file_path = os.path.join(
stub_generator.out_path, "{0}_python.json".format(apiview.name)
)
out_file_path = os.path.join(stub_generator.out_path, "{0}_python.json".format(apiview.package_name))
with open(out_file_path, "w") as json_file:
json_file.write(json_tokens)
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

if __name__ == "__main__":
console_entry_point()
exit(0)
exit(0)
Loading
Loading