Skip to content
This repository was archived by the owner on Mar 30, 2026. It is now read-only.

Commit d6cbe7a

Browse files
authored
📝 Bootstrap PyDocs (#171)
* add pydocs * regenerate pydocs * add initial pydoc workflow * update pydoc workflow * update pydoc workflow * update pydoc workflow * update pydoc workflow * update pydoc workflow * update pydoc workflow * update pydoc workflow * update pydoc workflow * update pydoc workflow * update pydoc workflow * update pydoc workflow * update pydoc workflow * update pydoc workflow * update relative path * fix docstrings * fix docstrings * replace double with single back ticks * fix docstrings and add examples * fix docstrings and add examples * remove python from code block * disable escape html chars * add python back to code block * test inline toc * remove inline toc * add post-render callback * add post render callback and template * remove unneeded md output * pip install editfrontmatter * replace .md with .py * removed pydoc output * update gitignore * update pydocs workflow
1 parent 57165bb commit d6cbe7a

9 files changed

Lines changed: 300 additions & 78 deletions

File tree

.github/workflows/pydocs.yml

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: PyDocs
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request_target:
8+
branches:
9+
- master
10+
11+
jobs:
12+
build:
13+
name: Generate docs
14+
runs-on: ubuntu-latest
15+
permissions:
16+
contents: read
17+
18+
steps:
19+
- name: Checkout repository
20+
uses: actions/checkout@v2
21+
22+
- name: Set up Python
23+
uses: actions/setup-python@v2
24+
with:
25+
python-version: '3.9'
26+
architecture: 'x64'
27+
28+
- name: Install dependencies
29+
run: |
30+
python -m pip install --upgrade pip
31+
python -m pip install pipx
32+
python -m pip install editfrontmatter
33+
pipx install 'pydoc-markdown>=4.0.0,<5.0.0'
34+
35+
- name: Generate markdown docs
36+
run: |
37+
pydoc-markdown -vv
38+
39+
- name: Upload markdown artifacts
40+
uses: actions/upload-artifact@v2
41+
with:
42+
name: docs-dir
43+
path: docs/
44+
45+
pull:
46+
name: Open pull request
47+
needs: build
48+
runs-on: ubuntu-latest
49+
50+
steps:
51+
- name: Checkout docs repository
52+
uses: actions/checkout@v2
53+
with:
54+
repository: 'PaloAltoNetworks/cortex.pan.dev'
55+
56+
- name: Download markdown artifacts
57+
uses: actions/download-artifact@v2
58+
with:
59+
name: docs-dir
60+
path: docs/
61+
62+
- name: Commit changes
63+
run: |
64+
git config --global user.email "sserrata@paloaltonetworks.com"
65+
git config --global user.name "Steven Serrata"
66+
git add .
67+
git commit -m "update pydocs"
68+
69+
- name: Create Pull Request
70+
id: pydocs
71+
uses: peter-evans/create-pull-request@v3
72+
with:
73+
token: ${{ secrets.PYDOC_TOKEN }}
74+
commit-message: Update pydocs
75+
committer: GitHub <noreply@github.com>
76+
author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
77+
delete-branch: true
78+
title: '[PyDocs] Update python library docs'
79+
body: |
80+
Update pydocs
81+
- Docs generated with `pydoc-markdown`
82+
83+
- name: Check outputs
84+
run: |
85+
echo "Pull Request Number - ${{ steps.pydocs.outputs.pull-request-number }}"
86+
echo "Pull Request URL - ${{ steps.pydocs.outputs.pull-request-url }}"

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,7 @@ target/
6969

7070
# IDE stuff
7171
.idea/*
72-
.vscode/*
72+
.vscode/*
73+
74+
# pydoc-markdown
75+
docs/**/*.md

docs/post_render.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
4+
5+
from editfrontmatter import EditFrontMatter
6+
import os
7+
import glob
8+
9+
10+
def main():
11+
template_str = "".join(open(os.path.abspath("docs/template.j2"), "r").readlines())
12+
md_files = glob.glob("./docs/**/*.md", recursive=True)
13+
for path in md_files:
14+
github_base_url = "https://github.com/PaloAltoNetworks/pan-cortex-data-lake-python/blob/master/pan_cortex_data_lake"
15+
github_file_path = path.split("/reference")[1].replace(".md", ".py")
16+
custom_edit_url = f"{github_base_url}{github_file_path}"
17+
proc = EditFrontMatter(file_path=path, template_str=template_str)
18+
proc.run({"custom_edit_url": custom_edit_url})
19+
proc.writeFile(path)
20+
21+
22+
if __name__ == "__main__":
23+
main()

docs/template.j2

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
custom_edit_url: {{ custom_edit_url }}

pan_cortex_data_lake/adapters/adapter.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def fetch_credential(self, credential=None, profile=None):
2222
2323
Args:
2424
credential (str): Credential to fetch.
25-
profile (str): Credentials profile. Defaults to ``'default'``.
25+
profile (str): Credentials profile. Defaults to 'default'.
2626
2727
"""
2828
pass
@@ -51,9 +51,9 @@ def write_credentials(self, credentials=None, profile=None, cache_token=None):
5151
:::
5252
5353
Args:
54-
cache_token (bool): If ``True``, stores ``access_token`` in token store. Defaults to ``True``.
54+
cache_token (bool): If `True`, stores `access_token` in token store. Defaults to `True`.
5555
credentials (class): Read-only credentials.
56-
profile (str): Credentials profile. Defaults to ``'default'``.
56+
profile (str): Credentials profile. Defaults to 'default'.
5757
5858
"""
5959
pass

0 commit comments

Comments
 (0)