ci(hack): add config-doc-generator (#101)

Co-authored-by: mzz2017 <2017@duck.com>
This commit is contained in:
Kevin Yu 2023-05-27 19:52:13 +08:00 committed by GitHub
parent d9f6fa7aee
commit 9e20a7fff6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 55 additions and 8 deletions

View File

@ -4,21 +4,21 @@ on:
push:
branches: [main]
paths:
- 'README*.md'
- 'README.md'
- 'docs/**'
- 'package.json'
- '.autocorrectrc'
- '.markdownlint-cli2.jsonc'
- '.github/workflows/check-docs.yaml'
- '.github/workflows/check-docs.yml'
pull_request:
branches: [main]
paths:
- 'README*.md'
- 'README.md'
- 'docs/**'
- 'package.json'
- '.autocorrectrc'
- '.markdownlint-cli2.jsonc'
- '.github/workflows/check-docs.yaml'
- '.github/workflows/check-docs.yml'
jobs:
check-doc:

2
docs/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
sync/*
!sync/.gitkeep

0
docs/sync/.gitkeep Normal file
View File

15
docs/templates/example-config.md vendored Normal file
View File

@ -0,0 +1,15 @@
---
sidebar_position: 7
---
# Example Config
Original Copy: <https://github.com/daeuniverse/dae/blob/main/example.dae>
<!-- START -->
```python
<!-- TEXT REPLACE -->
```
<!-- END -->

View File

@ -1,6 +1,5 @@
global {
##### Software options.
###
# tproxy port to listen on. It is NOT a HTTP/SOCKS port, and is just used by eBPF program.
# In normal case, you do not need to use it.
@ -14,7 +13,6 @@ global {
##### Interface and kernel options.
###
# The LAN interface to bind. Use it if you want to proxy LAN.
# Multiple interfaces split by ",".
@ -30,7 +28,6 @@ global {
##### Node connectivity check.
###
# Host of URL should have both IPv4 and IPv6 if you have double stack in local.
# First is URL, others are IP addresses if given.
@ -56,7 +53,6 @@ global {
##### Connecting options.
###
# Optional values of dial_mode are:
# 1. "ip". Dial proxy using the IP from DNS directly. This allows your ipv4, ipv6 to choose the optimal path

View File

@ -0,0 +1,34 @@
import re
def read_config(filename):
with open(filename, 'r') as f:
return ''.join(f.readlines())
def replacetext(src_file, dest_file, search_text, replace_text):
with open(src_file, 'r+') as src:
src_file = src.read() # Read
src.close()
with open(dest_file, 'w') as dest:
dest_file = re.sub(search_text, replace_text, src_file) # Replace
dest.seek(0) # Setting the position to the top of the page to insert data
dest.write(dest_file) # Write
dest.close()
def main():
search_text = '<!-- TEXT REPLACE -->'
replace_text = read_config('example.dae')
replacetext(
'docs/templates/example-config.md',
'docs/sync/example-config.md',
search_text,
replace_text,
)
if __name__ == '__main__':
main()