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 changes to add package name and version for python in review #1194

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 4 additions & 1 deletion packages/python-packages/api-stub-generator/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Release History

## Version 0.0.1 (Unreleased)
## Version 0.2.1 (Unreleased)
Added package name in review node

## Version 0.2.0 (Unreleased)
Added support for packages with non-azure root namespace

## Version 0.0.1 (Unreleased)
Expand Down
11 changes: 6 additions & 5 deletions packages/python-packages/api-stub-generator/apistub/_apiview.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from ._version import VERSION
from ._diagnostic import Diagnostic

JSON_FIELDS = ["Name", "Version", "VersionString", "Navigation", "Tokens", "Diagnostics"]
JSON_FIELDS = ["Name", "Version", "VersionString", "Navigation", "Tokens", "Diagnostics", "PackageName"]

HEADER_TEXT = "# Package is parsed using api-stub-generator(version:{})".format(VERSION)
TYPE_NAME_REGEX = re.compile("(~?[a-zA-Z\d._]+)")
Expand All @@ -29,17 +29,18 @@ class ApiView:
:param str: ver_string
"""

def __init__(self, nodeindex, pkg_name="", pkg_version=0, ver_string="", namespace = ""):
def __init__(self, nodeindex, pkg_name="", pkg_version="", namespace = ""):
self.Name = pkg_name
self.Version = pkg_version
self.VersionString = ver_string
self.Version = 0
self.VersionString = ""
Copy link
Contributor

Choose a reason for hiding this comment

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

Was this intentional? Wouldn't we want this meta-data?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yup. APIView tool sets these two fields when it parses ast.

self.Language = "Python"
self.Tokens = []
self.Navigation = []
self.Diagnostics = []
self.indent = 0
self.indent = 0
self.namespace = namespace
self.nodeindex = nodeindex
self.PackageName = pkg_name
self.add_literal(HEADER_TEXT)
self.add_new_line(2)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def _generate_tokens(self, pkg_root_path, package_name, version, namespace):
self.module_dict = {}
nodeindex = NodeIndex()
# todo (Update the version number correctly)
apiview = ApiView(nodeindex, package_name, 0, version, namespace)
apiview = ApiView(nodeindex, package_name, version, namespace)
modules = self._find_modules(pkg_root_path)
logging.debug("Modules to generate tokens: {}".format(modules))

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.

VERSION = "0.2.0"
VERSION = "0.2.1"
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class PythonLanguageService : LanguageProcessor
{
public override string Name { get; } = "Python";
public override string Extension { get; } = ".whl";
public override string VersionString { get; } = "0.1.3";
public override string VersionString { get; } = "0.2.1";

private readonly string _apiViewPythonProcessor;
public override string ProcessName => _apiViewPythonProcessor;
Expand Down