Skip to content
This repository has been archived by the owner on Nov 29, 2023. It is now read-only.

Commit

Permalink
feat: enhance extracted data for usage with API editor (#14)
Browse files Browse the repository at this point in the history
* feat: add new fields to model

* fix: get everything running again

* feat: clean docstrings

* feat: extract imports and from-imports for modules

* fix: use qualified name of functions as key

* fix: some linter errors

* fix: remaining linter errors
  • Loading branch information
lars-reimann authored Nov 5, 2021
1 parent cbad180 commit a19b551
Show file tree
Hide file tree
Showing 17 changed files with 443 additions and 138 deletions.
3 changes: 3 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[flake8]
extend-exclude = __init__.py
extend-ignore = E501
2 changes: 1 addition & 1 deletion .mega-linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ TYPESCRIPT_PRETTIER_FILE_EXTENSIONS:
# Commands
PRE_COMMANDS:
- command: npm install
cwd: root
cwd: workspace

# Linters
ENABLE_LINTERS:
Expand Down
1 change: 0 additions & 1 deletion .prettierrc.json

This file was deleted.

1 change: 1 addition & 0 deletions ontology/mostly_empty_file
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove this once other content is in the ontology folder
53 changes: 53 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "sem21",
"version": "0.0.1",
"private": true,
"prettier": "@lars-reimann/prettier-config",
"devDependencies": {
"@lars-reimann/prettier-config": "^4.0.1"
}
}
2 changes: 1 addition & 1 deletion package_parser/package_parser/__main__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from package_parser.main import main

if __name__ == '__main__':
if __name__ == "__main__":
main()
15 changes: 5 additions & 10 deletions package_parser/package_parser/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ def cli() -> None:
public_api = get_api(args.package)

out_dir: Path = args.out
out_file = out_dir.joinpath(f"{public_api.distribution}__{public_api.package}__{public_api.version}__api.json")
out_file = out_dir.joinpath(
f"{public_api.distribution}__{public_api.package}__{public_api.version}__api.json"
)
ensure_file_exists(out_file)
with out_file.open("w") as f:
json.dump(public_api.to_json(), f, indent=2)
Expand All @@ -33,10 +35,7 @@ def __get_args() -> argparse.Namespace:


def __add_api_subparser(subparsers: _SubParsersAction) -> None:
api_parser = subparsers.add_parser(
__API_COMMAND,
help="List the API of a package."
)
api_parser = subparsers.add_parser(__API_COMMAND, help="List the API of a package.")
api_parser.add_argument(
"-p",
"--package",
Expand All @@ -45,9 +44,5 @@ def __add_api_subparser(subparsers: _SubParsersAction) -> None:
required=True,
)
api_parser.add_argument(
"-o",
"--out",
help="Output directory.",
type=Path,
required=True
"-o", "--out", help="Output directory.", type=Path, required=True
)
20 changes: 18 additions & 2 deletions package_parser/package_parser/commands/get_api/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
from ._get_api import get_api
from ._model import API, Class, Function, Parameter, ParameterAssignment, ParameterDocstring
from ._package_metadata import distribution, distribution_version, package_files, package_root
from ._model import (
API,
Class,
FromImport,
Function,
Import,
Module,
Parameter,
ParameterAndResultDocstring,
ParameterAssignment,
Result,
)
from ._package_metadata import (
distribution,
distribution_version,
package_files,
package_root,
)
Loading

0 comments on commit a19b551

Please sign in to comment.