Skip to content

Commit

Permalink
More tidying
Browse files Browse the repository at this point in the history
  • Loading branch information
ollydev committed Nov 23, 2024
1 parent cb29146 commit 3fb4239
Show file tree
Hide file tree
Showing 53 changed files with 2,527 additions and 3,292 deletions.
24 changes: 2 additions & 22 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,33 +29,13 @@ jobs:
- uses: actions/[email protected]
with:
ref: ${{ github.event.workflow_run.head_branch }}
- name: Download artifact
uses: actions/github-script@v6
with:
script: |
let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.payload.workflow_run.id,
});
let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => {
return artifact.name == "Simba-Win32.exe"
})[0];
let download = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifact.id,
archive_format: 'zip',
});
let fs = require('fs');
fs.writeFileSync('Simba-Win32.zip', Buffer.from(download.data));

- name: Build files
shell: bash
run: |
pip3 install sphinx furo myst-parser
unzip Simba-Win32.zip
./Simba-Win32.exe --run "DocGen/docgen.simba"
cd DocGen
python3 docgen.py
- name: Setup Pages
uses: actions/configure-pages@v1
Expand Down
77 changes: 0 additions & 77 deletions DocGen/doccomments.simba

This file was deleted.

45 changes: 45 additions & 0 deletions DocGen/docgen.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# pip3 install sphinx furo myst-parser
# Theme is https://pradyunsg.me/furo/quickstart/

import os
import glob
import re
import subprocess

SRC_DIR = '../Source/script/imports/'
BUILD_DIR = 'source/api/'

# remove old build files, all but index
for file in glob.glob(f"{BUILD_DIR}*.md"):
os.remove(file)

# extract all comments
comments = []
for source in glob.glob(f"{SRC_DIR}*.pas"):
with open(source, 'r') as f:
comments.extend(re.findall(r'\(\*(.*?)\*\)', f.read(), re.DOTALL))

# write comments, changing the file when a header is found
# header being a === line rather than ---
currentfile = None
for comment in comments:
comment = comment.strip()
if (comment.splitlines()[1][0] == '='):
if currentfile:
currentfile.close()
currentfile = open(f"{BUILD_DIR}/{comment.splitlines()[0]}.md", 'a')
currentfile.write(comment)
else:
currentfile.write('\n\n' + '-----' + '\n\n' + comment)
if currentfile:
currentfile.close()

# build it
subprocess.run(["sphinx-build", "-q", "-E", "source", "build"])

# smaller text looks better for api declarations
for source in glob.glob("build/api/*.html"):
with open(source, 'r', encoding='utf-8') as f:
contents = f.read().replace("h2", "h3")
with open(source, 'w', encoding='utf-8') as f:
f.write(contents)
128 changes: 0 additions & 128 deletions DocGen/docgen.simba

This file was deleted.

1 change: 0 additions & 1 deletion DocGen/source/api/index.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

API
===

Expand Down
6 changes: 5 additions & 1 deletion Source/Simba.lpi
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@
<PackageName Value="LCL"/>
</Item5>
</RequiredPackages>
<Units Count="75">
<Units Count="76">
<Unit0>
<Filename Value="Simba.lpr"/>
<IsPartOfProject Value="True"/>
Expand Down Expand Up @@ -740,6 +740,10 @@
<Filename Value="script/simba.script_threading.pas"/>
<IsPartOfProject Value="True"/>
</Unit74>
<Unit75>
<Filename Value="simba.vartype_matrix.pas"/>
<IsPartOfProject Value="True"/>
</Unit75>
</Units>
</ProjectOptions>
<CompilerOptions>
Expand Down
Loading

0 comments on commit 3fb4239

Please sign in to comment.