Skip to content

Commit

Permalink
Set package version in API review code File for Python (#7305)
Browse files Browse the repository at this point in the history
* Set package version in API review code File for Python
  • Loading branch information
praveenkuttappan authored Nov 17, 2023
1 parent c4395d1 commit 8a5c76e
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 9 deletions.
5 changes: 4 additions & 1 deletion packages/python-packages/apiview-stub-generator/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Release History

## Version 0.3.9 (TBD)
## Version 0.3.10 (2023-11-17)
Update package version in API review codefile

## Version 0.3.9 (2023-11-17)
Improve support for "CrossLanguageDefinitionId".

## Version 0.3.8 (2023-07-06)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from ._diagnostic import Diagnostic
from ._metadata_map import MetadataMap

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

HEADER_TEXT = "# Package is parsed using apiview-stub-generator(version:{0}), Python version: {1}".format(VERSION, platform.python_version())
TYPE_NAME_REGEX = re.compile(r"(~?[a-zA-Z\d._]+)")
Expand Down Expand Up @@ -40,7 +40,7 @@ def get_root_path(cls):
path = os.path.split(path)[0]
return None

def __init__(self, *, pkg_name="", namespace = "", metadata_map=None, source_url=None):
def __init__(self, *, pkg_name="", namespace = "", metadata_map=None, source_url=None, pkg_version =""):
self.name = pkg_name
self.version = 0
self.version_string = VERSION
Expand All @@ -52,6 +52,7 @@ def __init__(self, *, pkg_name="", namespace = "", metadata_map=None, source_url
self.namespace = namespace
self.node_index = NodeIndex()
self.package_name = pkg_name
self.package_version = pkg_version
self.metadata_map = metadata_map or MetadataMap("")
self.add_token(Token("", TokenKind.SkipDiffRangeStart))
self.add_literal(HEADER_TEXT)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def generate_tokens(self):
namespace = self.filter_namespace

logging.debug("Generating tokens")
apiview = self._generate_tokens(pkg_root_path, pkg_name, namespace, source_url=self.source_url)
apiview = self._generate_tokens(pkg_root_path, pkg_name, namespace, version, source_url=self.source_url)
if apiview.diagnostics:
logging.info("*************** Completed parsing package with errors ***************")
else:
Expand Down Expand Up @@ -189,7 +189,7 @@ def _find_modules(self, pkg_root_path):
return sorted(modules)


def _generate_tokens(self, pkg_root_path, package_name, namespace, *, source_url):
def _generate_tokens(self, pkg_root_path, package_name, namespace, package_version, *, source_url):
"""This method returns a dictionary of namespace and all public classes in each namespace
"""
# Import ModuleNode.
Expand All @@ -203,7 +203,8 @@ def _generate_tokens(self, pkg_root_path, package_name, namespace, *, source_url
pkg_name=package_name,
namespace=namespace,
metadata_map=mapping,
source_url=source_url
source_url=source_url,
pkg_version=package_version
)
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.3.9"
VERSION = "0.3.10"
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
./
pylint-guidelines-checker==0.0.7
pylint-guidelines-checker==0.0.7
pylint<3.0.0
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class PythonLanguageService : LanguageProcessor
{
public override string Name { get; } = "Python";
public override string[] Extensions { get; } = { ".whl" };
public override string VersionString { get; } = "0.3.8";
public override string VersionString { get; } = "0.3.10";

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

0 comments on commit 8a5c76e

Please sign in to comment.