Skip to content

Commit

Permalink
Ensure code block starts new line
Browse files Browse the repository at this point in the history
  • Loading branch information
osrjv committed Sep 1, 2023
1 parent 6688cd3 commit ab6e17f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 16 deletions.
17 changes: 1 addition & 16 deletions src/lazydocs/generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,22 +305,6 @@ def _is_module_ignored(module_name: str, ignored_modules: List[str]) -> bool:
return False


def _get_src_root_path(obj: Any) -> str:
"""Get the root path to a imported module.
Args:
obj (Any): Imported python object.
Returns:
str: Full source root path to the selected object.
"""
module = obj
if not isinstance(obj, types.ModuleType):
module = inspect.getmodule(obj)
root_package = module.__name__.split(".")[0]
return module.__file__.split(root_package)[0] + root_package


def _get_doc_summary(obj: Any) -> str:
# First line should contain the summary
return _get_docstring(obj).split("\n")[0]
Expand Down Expand Up @@ -401,6 +385,7 @@ def _doc2md(obj: Any) -> str:
else:
md_code_snippet = True
snippet_indent = indent
out.append("\n")

out.append(line)
elif line.strip().endswith("::"):
Expand Down
5 changes: 5 additions & 0 deletions tests/resources/example/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ def a_public_function(required: int, optional: Optional[str] = None) -> AClass:
This is a second paragraph that should be separate.
This is not an actual header, but has a code-block underneath:
```python
print("Let's hope this works!")
```
Example:
```python
from example import a_public_function
Expand Down
5 changes: 5 additions & 0 deletions tests/test_markdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,8 @@ def test_multiple_paragraphs(markdown):

def test_source_link(markdown):
assert "_class.py:9" in markdown


def test_code_spacing(markdown):
# Ensure no code-blocks are escaped
assert "\\`" not in markdown

0 comments on commit ab6e17f

Please sign in to comment.