watch-build

This commit is contained in:
ousttrue
2021-09-06 15:34:29 +09:00
parent a26162d474
commit 58b44f68f5
4 changed files with 93 additions and 4 deletions

View File

@@ -12,6 +12,12 @@
"args": [
"copy-csproj"
]
},
{
"name": "watch-build",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/watch_build.py",
}
]
}

View File

@@ -6,6 +6,8 @@
* [docfx](https://dotnet.github.io/docfx/)(2系)
* python3
* pip install invoke
* pip install watchdog
# 記事の更新
@@ -59,3 +61,40 @@ docfx$ docfx --serve
```
docfx$ docfx build
```
## github actions
`.github/workflows/docfx.yml`
```yml
name: DocFX
on:
push:
branches:
- master
jobs:
build:
runs-on: windows-2019
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 1
# build docfx site to docfx/_site
- name: DocFX
shell: cmd
run: |
choco install docfx -y
docfx docfx\docfx.json
# push docfx/_site to gh-pages
- name: Publish Documentation on GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: docfx/_site
```

View File

@@ -1,4 +1,3 @@
# This is the **HOMEPAGE**.
Refer to [Markdown](http://daringfireball.net/projects/markdown/) for how to write markdown files.
## Quick Start Notes:
1. Add images to the *images* folder if the file is referencing an image.
# UniVRM Programming Document
index

45
docfx/watch_build.py Normal file
View File

@@ -0,0 +1,45 @@
import sys
import time
import subprocess
from watchdog.observers import Observer
from watchdog.events import PatternMatchingEventHandler
import pathlib
HERE = pathlib.Path(__file__).absolute().parent
class MyHandler(PatternMatchingEventHandler):
def __init__(self):
super(MyHandler, self).__init__(patterns='*.yml;*.md')
def _run_command(self):
subprocess.call(['docfx.exe', 'build'])
def on_moved(self, event):
self._run_command()
def on_created(self, event):
self._run_command()
def on_deleted(self, event):
self._run_command()
def on_modified(self, event):
self._run_command()
def watch():
event_handler = MyHandler()
observer = Observer()
observer.schedule(event_handler, HERE, recursive=True)
observer.start()
try:
while True:
time.sleep(1)
except KeyboardInterrupt:
observer.stop()
observer.join()
if __name__ == "__main__":
watch()