-
Notifications
You must be signed in to change notification settings - Fork 186
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Python APIView] CrossLangugageDefintionId implementation (#2781)
* Refactor APIView primitives to use snake_case instead of PascalCase. Add apiview_mapping file. * Implement CrossLanguageDefinitionId for classes and functions. * Code review feedback. * Support --mapping-path arg for parsing WHL files.
- Loading branch information
1 parent
227cbcd
commit 77c0f52
Showing
14 changed files
with
122 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 4 additions & 12 deletions
16
packages/python-packages/api-stub-generator/apistub/_diagnostic.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,9 @@ | ||
import logging | ||
|
||
class Diagnostic: | ||
id_counter = 1 | ||
|
||
def __init__(self, target_id, message): | ||
self.DiagnosticId = "AZ_PY_{}".format(Diagnostic.id_counter) | ||
self.diagnostic_id = "AZ_PY_{}".format(Diagnostic.id_counter) | ||
Diagnostic.id_counter+=1 | ||
self.Text = message | ||
self.HelpLinkUri = "" | ||
self.TargetId = target_id | ||
|
||
def set_text(self, text): | ||
self.Text = text | ||
|
||
def set_helplink(self, helplink): | ||
self.HelpLinkUri = helplink | ||
self.text = message | ||
self.help_link_uri = "" | ||
self.target_id = target_id |
32 changes: 32 additions & 0 deletions
32
packages/python-packages/api-stub-generator/apistub/_metadata_map.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/usr/bin/env python | ||
|
||
# -------------------------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for license information. | ||
# -------------------------------------------------------------------------------------------- | ||
|
||
import json | ||
import os | ||
|
||
MAPPING_FILE_NAME = "apiview_mapping.json" | ||
|
||
""" | ||
Loads metadata from the mapping file for use | ||
by the stub generator. | ||
""" | ||
class MetadataMap: | ||
|
||
def __init__(self, pkg_path, mapping_path=None): | ||
if not mapping_path: | ||
if pkg_path.endswith(".whl") or pkg_path.endswith(".zip"): | ||
self.cross_language_map = {} | ||
return | ||
mapping_path = os.path.join(pkg_path, MAPPING_FILE_NAME) | ||
|
||
try: | ||
with open(mapping_path, "r") as json_file: | ||
mapping = json.load(json_file) | ||
self.cross_language_map = mapping.get("CrossLanguageDefinitionId", {}) | ||
except OSError: | ||
self.cross_language_map = {} | ||
return |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.