Files
OpenBB/tests/website/test_generate_docs.py
teh_coderer 79046608b6 Docs Fix (#3543)
* Update generate_terminal_markdown.py

* updates

* update workflows

* Automated Change

* tests

* tests

* Automated Change

* Update test_generate_docs.py

* Automated Change

* updates

* Automated Change

* Update gen-docs.yml

* Update test.yml

* Automated Change

* Update test.yml

* Automated Change

* Update generate_sdk_markdown.py

* Automated Change

* test

* Automated Change

* testtt23

* Automated Change

* Update generate_sdk_markdown.py

* Automated Change

* Automated Change

* added empting reference folders before autogen docs

* updates

* Automated Change

* update tests gitactions

* Automated Change

* up

* Automated Change

* Automated Change

* update pytest

* Automated Change

* tests

* Automated Change

* examples update

* Automated Change

* Update generate_sdk_markdown.py

* Automated Change

* Update test.yml

* Update generate_sdk_markdown.py

* strip

* Automated Change

* Workflow : check test update

* Automated Change

* Automated Change

* Automated Change

* Update test.yml

* Automated Change

* Update test.yml

* Automated Change

* Automated Change

* up

* Automated Change

* Update generate_sdk_markdown.py

* Automated Change

* update workflows

* fix guides

* testing

* Update gh-pages.yml

* Update gh-pages.yml

Co-authored-by: tehcoderer <tehcoderer@users.noreply.github.com>
Co-authored-by: Jeroen Bouma <jer.bouma@gmail.com>
Co-authored-by: Chavithra PARANA <chavithra@gmail.com>
Co-authored-by: Chavithra <Chavithra@users.noreply.github.com>
Co-authored-by: jose-donato <43375532+jose-donato@users.noreply.github.com>
Co-authored-by: jose-donato <jose-donato@users.noreply.github.com>
2022-11-25 17:19:08 -05:00

97 lines
2.4 KiB
Python

from typing import Optional
from website import (
generate_sdk_markdown as gen_sdk,
generate_terminal_markdown as gen_term,
)
def test_generate_terminal_markdown():
"""Test the terminal markdown generator"""
assert gen_term.main() is True
def test_generate_sdk_markdown():
"""Test the sdk markdown generator"""
assert gen_sdk.main() is True
def mock_func(arg1: Optional[str] = "Test", arg2: Optional[bool] = True) -> bool:
"""Stuff here or stuff there, it doesn't matter, it's everywhere.
Parameters
----------
arg1 : Optional[str]
The first argument, by default "Test"
arg2 : Optional[bool]
The second argument, by default True
Returns
-------
bool
The return value.
"""
del arg1, arg2
return True
class MockTrailMap:
"""Mock trail map"""
def __init__(self):
self.trailmap = ""
self.func_attr = {"model": mock_func}
self.class_attr = {"model": "mock"}
self.lineon = {"model": 69}
self.full_path = {"model": "test/mock_func.py"}
self.model = "mock_func"
self.long_doc = {"model": mock_func.__doc__}
self.func_def = {
"model": 'openbb.mock(arg1: Optional[str] = "Test", arg2: Optional[bool] = True)'
}
self.params = {"model": {}}
for k, p in gen_sdk.get_signature_parameters(
mock_func, mock_func.__globals__
).items():
self.params["model"][k] = p
EXPECTED_OUTPUT = """Stuff here or stuff there, it doesn't matter, it's everywhere.
Source Code: [[link](https://github.com/OpenBB-finance/OpenBBTerminal/tree/main/test/mock_func.py#L69)]
```python
openbb.mock(arg1: Optional[str] = "Test", arg2: Optional[bool] = True)
```
---
## Parameters
| Name | Type | Description | Default | Optional |
| ---- | ---- | ----------- | ------- | -------- |
| arg1 | Optional[str] | The first argument, by default "Test" | Test | True |
| arg2 | Optional[bool] | The second argument, by default True | True | True |
---
## Returns
| Type | Description |
| ---- | ----------- |
| bool | The return value. |
---
"""
def test_sdk_docstring_to_markdown():
"""Test the docstring to markdown converter"""
mock = MockTrailMap()
func_meta = gen_sdk.get_function_meta(mock, "model")
result = gen_sdk.generate_markdown_section(func_meta)
assert result == EXPECTED_OUTPUT