FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
docs.libdebug.github.io/rolling/scrape_code.py at main · libdebug/docs.libdebug.github.io · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
libdebug
/
docs.libdebug.github.io
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
docs.libdebug.github.io
/
rolling
/
scrape_code.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
49 lines (35 loc) · 1.58 KB
Breadcrumbs
docs.libdebug.github.io
/
rolling
/
scrape_code.py
Copy path
File metadata and controls
49 lines (35 loc) · 1.58 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import
os
folder_to_scrape
=
"../libdebug"
out_folder
=
"./from_pydoc/generated"
if
os
.
path
.
exists
(
out_folder
):
os
.
system
(
f"rm -rf
{
out_folder
}
"
)
def
create_if_not_exists
(
folder
):
if
not
os
.
path
.
exists
(
folder
):
os
.
makedirs
(
folder
)
def
md_rename
(
file
):
return
file
.
replace
(
".py"
,
".md"
)
for
root
,
dirs
,
files
in
os
.
walk
(
folder_to_scrape
):
for
file
in
files
:
# Skip init files and such
if
file
.
startswith
(
"_"
):
continue
# Only scrape .py, .c, and .h files
if
file
.
endswith
(
".py"
):
file_path
=
os
.
path
.
join
(
root
,
file
)
print
(
f"File path:
{
file_path
}
"
)
# File path relative to libdebug/libdebug
file_path
=
file_path
.
replace
(
folder_to_scrape
+
"/"
,
""
)
print
(
f"Scraping
{
file_path
}
"
)
if
"/"
in
file_path
:
folder_to_create
=
os
.
path
.
join
(
out_folder
,
file_path
[:
file_path
.
rfind
(
"/"
)])
else
:
folder_to_create
=
out_folder
create_if_not_exists
(
folder_to_create
)
print
(
f"Creating folder
{
folder_to_create
}
"
)
new_file_path
=
os
.
path
.
join
(
folder_to_create
,
md_rename
(
file
))
print
(
f"Creating
{
new_file_path
}
"
)
# Write the file, including a yml header to avoid search priority problems
with
open
(
new_file_path
,
"w"
)
as
f
:
module_name
=
"libdebug."
+
file_path
.
split
(
"."
)[
0
].
replace
(
"/"
,
"."
)
what_to_write
=
f"---
\n
title:
{
module_name
}
\n
boost: 0.5
\n
---
\n
#
{
module_name
}
\n
:::
{
module_name
}
\n
"
f
.
write
(
what_to_write
)
Back
|
FazBrowse Home
|
New Git URL