-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding workflow to create Cordio platform docs. #403
Changes from 57 commits
49c16ab
12d3122
d13c4ed
9a5084e
b22ebc1
359ffcc
10b76ce
eca528e
da9e4d1
d619936
2193526
bb9c3e5
0612138
0ab3d8e
dad8a39
88e6e3f
463c252
e1f65cc
c5b5389
e33336a
86e4ea4
734f2c4
37b06d4
ed7c8f5
b975c8e
e2f69c3
906504c
de1af34
85b6ed5
db5cb6b
02cf2bf
fa1ef84
2f5fa48
f50d42c
a2a5b20
39b1038
0f46361
f325aa3
8a8a6fd
df93989
88f839e
19d5212
9de0369
3b071e9
001c921
8a15065
90d139b
de1cba9
e23acda
6dca17d
a6ce51f
b6131eb
08d314b
4571101
ac70b71
a839525
9d1fa5c
635a4cb
12b7b3e
9d122eb
501a0e5
1c45b98
b5456a0
65fda10
1c8d339
0b169d0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
name: Build & Deploy Cordio Platform Docs | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/github-script@v3 | ||
id: get-pr | ||
with: | ||
script: | | ||
const request = { | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
pull_number: context.issue.number | ||
} | ||
core.info(`Getting PR #${request.pull_number} from ${request.owner}/${request.repo}`) | ||
try { | ||
const result = await github.pulls.get(request) | ||
return result.data | ||
} catch (err) { | ||
core.setFailed(`Request failed with error ${err}`) | ||
} | ||
- uses: actions/checkout@v3 | ||
with: | ||
repository: ${{ fromJSON(steps.get-pr.outputs.result).head.repo.full_name }} | ||
ref: ${{ fromJSON(steps.get-pr.outputs.result).head.ref }} | ||
fetch-depth: 0 | ||
|
||
- name: Generate Docs (MAX32655) | ||
uses: mattnotmitt/[email protected] | ||
with: | ||
working-directory: Libraries/Cordio/docs | ||
doxyfile-path: cordio_platform_doxyfile | ||
enable-latex: true | ||
|
||
- name: Build PDF | ||
run: | | ||
echo "Building PDF..." | ||
sudo apt-get install texlive-full | ||
sudo make -C Libraries/Cordio/docs/latex | ||
|
||
echo "Copying PDF to Cordio/platform/Documentation" | ||
sudo mv Libraries/Cordio/docs/latex/refman.pdf Libraries/Cordio/docs/latex/Cordio-Platform-Documentation.pdf | ||
sudo mkdir -p Libraries/Cordio/platform/Documentation && sudo cp -r Libraries/Cordio/docs/latex/Cordio-Platform-Documentation.pdf Libraries/Cordio/platform/Documentation/ | ||
|
||
|
||
- name: Push Documentation Files | ||
uses: EndBug/[email protected] | ||
with: | ||
add: 'Libraries/Cordio/platform/Documentation/Platform_ref.pdf' | ||
message: 'Update documentation.' | ||
push: true | ||
|
||
|
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1584,6 +1584,12 @@ The Cordio Bluetooth Low Energy (BLE) library provides a full BLE stack for micr | |
- MAX32680 | ||
- MAX32690 | ||
|
||
#### Cordio Documentation | ||
|
||
- [Architecture](ARCHITECTURE.md) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we'll have to add a path for these links to work. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. tested it a couple different times on my machine, since the workflow copies those files in the same directory as the userguide.md file , pathing like this works fine There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we look at this file in the main branch then the path will be wrong. I don't think we should permanently copy the markdown files into this directory. |
||
- [Bluetooth LE Basics](BLUETOOTH_LE_BASICS.md) | ||
- [Packetcraft](PACKETCRAFT.md) | ||
|
||
--- | ||
|
||
### MAXUSB | ||
|
@@ -1617,3 +1623,4 @@ The **Secure Digital High Capacity *(SDHC)*** library offers a higher-level inte | |
- MAX32570 | ||
- MAX32665-MAX32668 | ||
- MAX78002 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
from pathlib import Path | ||
from os import listdir | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So this looks for markdown files and PDFs and adds links to USERGUIDE.md? Maybe we should move this to the workflows folder? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. moved, but we will have to do a test to double check the new pathing from that file |
||
|
||
TEMPLATE = "- [%s](%s)\n" | ||
here = Path.cwd() | ||
repo = here.parent | ||
cordio_docs_dir = repo / "Libraries" / "Cordio" / "docs" | ||
platform_docs_dir = repo / "Libraries" / "Cordio" / "platform" / "Documentation" | ||
|
||
cordio_doc_files = [f for f in listdir(cordio_docs_dir) if f.endswith('.md')] | ||
platform_doc_files = [f for f in listdir(platform_docs_dir) if f.endswith('.pdf')] | ||
|
||
with open('USERGUIDE.md', 'r') as f: | ||
lines = f.readlines() | ||
|
||
idx = 0 | ||
foundStart = False | ||
|
||
for line in lines: | ||
if foundStart: | ||
if line[0] == '#': | ||
end_idx = idx | ||
break | ||
|
||
if '#### Cordio Documentation' in line: | ||
start_idx = idx | ||
foundStart = True | ||
|
||
idx += 1 | ||
|
||
comp_lines = lines[start_idx+1:end_idx] | ||
new_files = cordio_doc_files + platform_doc_files | ||
|
||
for cfile in cordio_doc_files: | ||
for line in lines: | ||
if cfile in line: | ||
new_files.remove(cfile) | ||
|
||
for pfile in platform_doc_files: | ||
for line in lines: | ||
if pfile in line: | ||
new_files.remove(pfile) | ||
|
||
if len(new_files) > 0: | ||
entries = [] | ||
for f in new_files: | ||
if 'LICENSE' in f: | ||
continue | ||
nav_name = f.split('.')[0].title() | ||
entries.append(TEMPLATE % (nav_name, f)) | ||
|
||
while True: | ||
if lines[end_idx][0] == '-': | ||
end_idx -= 1 | ||
break | ||
end_idx -= 1 | ||
|
||
idx = 0 | ||
for entry in entries: | ||
lines.insert(end_idx, entry) | ||
end_idx += 1 | ||
|
||
content = "".join(lines) | ||
|
||
with open('USERGUIDE.md', 'w') as f: | ||
f.write(content) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This filename looks okay, we just need to update what's currently in the PR.