mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-22 12:30:19 +00:00
add references
This commit is contained in:
parent
5725d66113
commit
63db196bf9
1
.github/workflows/website.yml
vendored
1
.github/workflows/website.yml
vendored
@ -29,6 +29,7 @@ jobs:
|
||||
actions-cache-folder: 'emsdk-cache'
|
||||
- name: Compile
|
||||
run: |
|
||||
python scripts/build_references.py
|
||||
bash build_web.sh
|
||||
mv web docs/.retype/static
|
||||
###################################################
|
||||
|
2
.gitignore
vendored
2
.gitignore
vendored
@ -28,3 +28,5 @@ main
|
||||
pocketpy.dSYM
|
||||
libpocketpy.dylib.dSYM/
|
||||
main.dSYM/
|
||||
|
||||
docs/references.md
|
@ -380,6 +380,7 @@ public:
|
||||
PyObject* new_user_object(Args&&... args){
|
||||
return heap.gcnew<T>(_tp_user<T>(), std::forward<Args>(args)...);
|
||||
}
|
||||
#endif
|
||||
|
||||
template<typename T>
|
||||
Type _find_type_in_cxx_typeid_map(){
|
||||
@ -395,7 +396,6 @@ public:
|
||||
}
|
||||
return it->second;
|
||||
}
|
||||
#endif
|
||||
|
||||
/********** private **********/
|
||||
virtual ~VM();
|
||||
|
40
scripts/build_references.py
Normal file
40
scripts/build_references.py
Normal file
@ -0,0 +1,40 @@
|
||||
import re
|
||||
|
||||
filepath = 'include/pocketpy/vm.h'
|
||||
|
||||
with open(filepath, 'r', encoding='utf-8') as f:
|
||||
lines = f.readlines()
|
||||
|
||||
REGION_PATTERN = re.compile(r'#if PK_REGION\("(.+)"\)')
|
||||
|
||||
current_region = None
|
||||
output = []
|
||||
|
||||
def parse_line(line: str):
|
||||
output.append(line)
|
||||
|
||||
for line in lines:
|
||||
if current_region:
|
||||
if line.startswith('#endif'):
|
||||
current_region = None
|
||||
output.append('```\n\n')
|
||||
else:
|
||||
parse_line(line.strip(' '))
|
||||
else:
|
||||
m = REGION_PATTERN.match(line)
|
||||
if m:
|
||||
current_region = m.group(1)
|
||||
output.append(f'### {current_region}\n')
|
||||
output.append('```cpp\n')
|
||||
|
||||
with open('docs/references.md', 'w', encoding='utf-8') as f:
|
||||
f.write('''---label: References
|
||||
icon: code
|
||||
order: 2
|
||||
---
|
||||
|
||||
''')
|
||||
content = ''.join(output)
|
||||
# replace {...} to ; (multi-line match)
|
||||
content = re.sub(r'{(.+?)}', r';', content, flags=re.DOTALL)
|
||||
f.write(content)
|
Loading…
x
Reference in New Issue
Block a user