Skip to content

Commit 2ac9a87

Browse files
authored
fix: docs formatting (#6)
1 parent c8469e3 commit 2ac9a87

File tree

8 files changed

+104
-113
lines changed

8 files changed

+104
-113
lines changed

Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,11 @@ test-examples:
1919

2020
mypy:
2121
uv run mypy stackone_ai
22+
23+
docs-serve:
24+
uv run scripts/build_docs.py
25+
uv run mkdocs serve
26+
27+
docs-build:
28+
uv run scripts/build_docs.py
29+
uv run mkdocs build

examples/available_tools.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
4. Filtering by specific operations
99
5. Combining multiple operation patterns
1010
11-
# TODO: experimental - get_available_tools(account_id="your_account_id")
11+
TODO: experimental - get_available_tools(account_id="your_account_id")
1212
1313
```bash
1414
uv run examples/available_tools.py

examples/file_uploads.py

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""
2-
Example demonstrating file upload functionality with StackOne.
3-
Shows how to upload an employee document using the HRIS integration.
2+
Example demonstrating file upload functionality using StackOne.
3+
Shows how to upload an employee document using an HRIS integration.
44
55
This example is runnable with the following command:
66
```bash
@@ -21,11 +21,13 @@
2121
account_id = "45072196112816593343"
2222
employee_id = "c28xIQaWQ6MzM5MzczMDA2NzMzMzkwNzIwNA"
2323

24+
"""
25+
## Resume content
2426
25-
def upload_employee_document() -> None:
26-
"""Demonstrate uploading an employee document using StackOne."""
27-
with tempfile.TemporaryDirectory() as temp_dir:
28-
resume_content = """
27+
This is a sample resume content that will be uploaded to StackOne.
28+
"""
29+
30+
resume_content = """
2931
JOHN DOE
3032
Software Engineer
3133
@@ -38,9 +40,18 @@ def upload_employee_document() -> None:
3840
EDUCATION
3941
BS Computer Science
4042
University of Technology
41-
2016-2020
42-
"""
43+
2016-2020 """
44+
4345

46+
"""
47+
## Upload employee document
48+
49+
This function uploads a resume using the `hris_upload_employee_document` tool.
50+
"""
51+
52+
53+
def upload_employee_document() -> None:
54+
with tempfile.TemporaryDirectory() as temp_dir:
4455
resume_file = Path(temp_dir) / "resume.pdf"
4556
resume_file.write_text(resume_content)
4657

examples/index.py

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,58 @@
11
"""
2-
# Getting Started
3-
42
StackOne AI provides a unified interface for accessing various SaaS tools through AI-friendly APIs.
53
64
## Installation
75
86
```bash
7+
# Using pip
98
pip install stackone-ai
10-
```
119
10+
# Using uv
11+
uv add stackone-ai
12+
```
1213
13-
## Quick Start
14+
## How to use these docs
1415
15-
Here's a simple example. All examples are complete and runnable.
16+
All examples are complete and runnable.
17+
We use [uv](https://docs.astral.sh/uv/getting-started/installation/) for python dependency management.
1618
17-
You can even run the example directly from the command line:
19+
To run this example, install the dependencies (one-time setup) and run the script:
1820
1921
```bash
22+
uv sync --all-extras
2023
uv run examples/index.py
2124
```
22-
"""
2325
24-
from dotenv import load_dotenv
26+
## Package Usage
27+
"""
2528

2629
from stackone_ai import StackOneToolSet
2730

2831
"""
29-
## Authenticate with StackOne
32+
## Authentication
33+
34+
Set the `STACKONE_API_KEY` environment variable:
3035
3136
```bash
3237
export STACKONE_API_KEY=<your-api-key>
3338
```
3439
3540
or load from a .env file:
3641
"""
42+
from dotenv import load_dotenv
3743

3844
load_dotenv()
3945

4046
"""
4147
## Account IDs
4248
4349
StackOne uses account IDs to identify different integrations.
44-
See the example [stackone_account_ids.py](stackone_account_ids.py) for more details.
45-
This example will hardcode the account ID.
50+
See the example [stackone-account-ids.md](stackone-account-ids.md) for more details.
51+
52+
This example will hardcode the account ID:
4653
"""
4754

4855
account_id = "45072196112816593343"
49-
employee_id = "c28xIQaWQ6MzM5MzczMDA2NzMzMzkwNzIwNA"
5056

5157

5258
def quickstart():
@@ -56,11 +62,11 @@ def quickstart():
5662
tools = toolset.get_tools("hris_*", account_id=account_id)
5763

5864
# Use a specific tool
59-
employee_tool = tools.get_tool("hris_get_employee")
65+
employee_tool = tools.get_tool("hris_list_employees")
6066
assert employee_tool is not None
6167

62-
employee = employee_tool.execute({"id": employee_id})
63-
assert employee is not None
68+
employees = employee_tool.execute()
69+
assert employees is not None
6470

6571

6672
if __name__ == "__main__":
@@ -71,8 +77,8 @@ def quickstart():
7177
7278
Check out some more documentation:
7379
74-
- [Error Handling](error-handling.md)
7580
- [StackOne Account IDs](stackone-account-ids.md)
81+
- [Error Handling](error-handling.md)
7682
- [Available Tools](available-tools.md)
7783
- [File Uploads](file-uploads.md)
7884

mkdocs.yml

Lines changed: 34 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -6,48 +6,46 @@ repo_name: StackOneHQ/stackone-ai-python
66
docs_dir: .docs
77

88
theme:
9-
name: material
10-
palette:
11-
- media: "(prefers-color-scheme: light)"
12-
scheme: default
13-
primary: black
14-
accent: teal
15-
toggle:
16-
icon: material/brightness-7
17-
name: Switch to dark mode
18-
- media: "(prefers-color-scheme: dark)"
19-
scheme: slate
20-
primary: teal
21-
accent: black
22-
toggle:
23-
icon: material/brightness-4
24-
name: Switch to light mode
9+
name: terminal
10+
palette: default
2511
features:
26-
- navigation.instant
27-
- navigation.tracking
28-
- navigation.sections
29-
- navigation.expand
30-
- navigation.indexes
31-
- toc.follow
32-
- content.code.copy
12+
- footer.prev_next
13+
- navigation.side.indexes
14+
- navigation.side.toc.hide
15+
- revision.date
16+
- revision.history
17+
- style.links.underline.hide
3318

3419
markdown_extensions:
35-
- pymdownx.highlight:
36-
anchor_linenums: true
37-
- pymdownx.inlinehilite
38-
- pymdownx.snippets
39-
- pymdownx.superfences
40-
- admonition
41-
- pymdownx.details
4220
- attr_list
21+
- def_list
22+
- footnotes
4323
- md_in_html
24+
- meta
25+
- toc:
26+
permalink: "#"
27+
permalink_title: Anchor link to this section for reference
28+
- pymdownx.caret
29+
- pymdownx.mark
30+
- pymdownx.tilde
31+
- pymdownx.snippets:
32+
base_path:
33+
- .docs
34+
- pymdownx.superfences
35+
- pymdownx.highlight:
36+
use_pygments: true
37+
pygments_style: lovelace
38+
noclasses: true
39+
- pymdownx.inlinehilite
4440

4541
nav:
4642
- Home: index.md
47-
- Examples:
48-
- OpenAI Integration: openai-integration.md
49-
- CrewAI Integration: crewai-integration.md
50-
- LangChain Integration: langchain-integration.md
43+
- Usage:
5144
- StackOne Account IDs: stackone-account-ids.md
52-
- Error Handling: error-handling.md
53-
- File Uploads: file-uploads.md
45+
- Error Handling: error-handling.md
46+
- Available Tools: available-tools.md
47+
- File Uploads: file-uploads.md
48+
- Integrations:
49+
- OpenAI: openai-integration.md
50+
- CrewAI: crewai-integration.md
51+
- LangChain: langchain-integration.md

pyproject.toml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,10 @@ examples = [
3636
"python-dotenv>=1.0.1",
3737
]
3838
docs = [
39-
"mkdocs-material>=9.6.4",
40-
]
41-
pymdown-extensions = [
42-
"mkdocs-material>=9.6.4",
43-
]
39+
"mkdocs-terminal>=4.7.0",
40+
"pygments>=2.12",
41+
"pymdown-extensions"
42+
]
4443

4544
[dependency-groups]
4645
dev = [
@@ -66,7 +65,7 @@ markers = [
6665
"bin/**.py" = ["T201", "T203"]
6766
"scripts/**.py" = ["T201", "T203"]
6867
"tests/**.py" = ["T201", "T203"]
69-
"examples/**.py" = ["T201", "T203", "E501", "F841"]
68+
"examples/**.py" = ["T201", "T203", "E501", "F841", "E402"]
7069

7170
[tool.ruff]
7271
line-length = 110

scripts/build_docs.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@ def convert_file_to_markdown(py_file: Path) -> str:
1717
output = [f"# {title}\n"]
1818

1919
# Find all docstrings and their positions
20-
docstring_pattern = r'"""(.*?)"""'
20+
# Match docstrings that start and end on their own lines
21+
docstring_pattern = r'(\n|\A)\s*"""(.*?)"""(\s*\n|\Z)'
2122
current_pos = 0
2223

2324
for match in re.finditer(docstring_pattern, content, re.DOTALL):
2425
start, end = match.span()
26+
docstring_content = match.group(2).strip() # The actual docstring content is in group 2
2527

2628
# If there's code before this docstring, wrap it
2729
if current_pos < start:
@@ -32,7 +34,7 @@ def convert_file_to_markdown(py_file: Path) -> str:
3234
output.append("```\n")
3335

3436
# Add the docstring content as markdown
35-
output.append(match.group(1).strip())
37+
output.append(docstring_content)
3638
current_pos = end
3739

3840
# Add any remaining code

0 commit comments

Comments
 (0)