-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
172 additions
and
68 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import ast | ||
import inspect | ||
from typing import List | ||
|
||
import _ast | ||
from mkapi.core.module import Module, get_module | ||
from mkapi.core.object import get_object | ||
|
||
|
||
def get_source(module: Module, filters: List[str] = None) -> str: | ||
"""Returns a source for module.""" | ||
with open(module.sourcefile, "r") as f: | ||
source = f.read().strip() | ||
if not source: | ||
return "" | ||
# return f"[DOCS](../{module.object.id}.md#{module.object.id})\n\n~~~python\n{source}\n~~~\n" | ||
return source | ||
|
||
|
||
# module = get_module("mkapi.core.base") | ||
# | ||
# source = get_source(module) | ||
# | ||
# module.object.id | ||
# module.objects | ||
# | ||
# obj = get_object(module.objects[0]) | ||
# inspect.getsourcelines(obj) | ||
# | ||
# node = ast.parse(source) | ||
# for x in ast.iter_child_nodes(node): | ||
# if isinstance(x, _ast.ClassDef): | ||
# break | ||
# | ||
# x.lineno | ||
# ast.get_source_segment(source, x) | ||
# x.end_lineno | ||
# dir(x) | ||
# for a in ast.walk(x): | ||
# print(a) |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
# ![mkapi]({{ module.object.id }}{{ module_filter }}|link|plain) | ||
|
||
{% if module.object.kind == 'module' %} | ||
{% for object in module.objects %} | ||
{% if 'noheading' in object_filter %} | ||
{% if module.object.kind == 'module' -%} | ||
{% for object in module.objects -%} | ||
{% if 'noheading' in object_filter -%} | ||
![mkapi]({{ object }}{{ object_filter }}) | ||
{% else %} | ||
{% else -%} | ||
## ![mkapi]({{ object }}{{ object_filter }}) | ||
{% endif %} | ||
{% endfor %} | ||
{% else %} | ||
{% for member in module.members %} | ||
{% if member.docstring %} | ||
{% endif -%} | ||
{% endfor -%} | ||
{% else -%} | ||
{% for member in module.members -%} | ||
{% if member.docstring -%} | ||
## ![mkapi]({{ member.object.id }}{{ module_filter }}|apilink|plain) | ||
{% endif %} | ||
{% endfor %} | ||
{% endif %} | ||
{% endif -%} | ||
{% endfor -%} | ||
{% endif -%} |
Oops, something went wrong.