Skip to content

Commit 09c756f

Browse files
committed
Extract the doc ourselves if needed
1 parent 935171b commit 09c756f

File tree

3 files changed

+13
-19
lines changed

3 files changed

+13
-19
lines changed

generate_ghidra_pyi.py

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,7 @@
1919
def main():
2020
# type: () -> None
2121
if not helper.are_docs_available():
22-
continue_without_docs = askYesNo(
23-
'Missing API Documentation',
24-
'Ghidra API documentation is missing.\n'
25-
'Documentation is required to generate docstrings,\n'
26-
'argument names, and to find some of the classes.\n'
27-
'\n'
28-
'Would you like to continue without the API documentation?',
29-
)
30-
31-
if not continue_without_docs:
32-
print('Generation canceled: Missing API documentation.')
33-
print('To make the API documentation available, ', end='')
34-
print('click "Ghidra API Help" in the "Help" menu.')
35-
print('Once the extraction is complete, re-run this script to generate the .pyi files.')
36-
return
37-
38-
print('Continuing without API documentation. Expect partial results.')
39-
22+
helper.extract_jsondoc()
4023
try:
4124
pyi_root = askDirectory('.pyi root directory', 'Select').getPath()
4225
print(pyi_root)

generate_stub_package.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def generate_package(pyi_root, ghidra_version):
99
1010
def find_stub_files():
1111
result = []
12-
package = 'ghidra'
12+
package = 'ghidra-stubs'
1313
for root, dirs, files in os.walk(package):
1414
for file in files:
1515
if file.endswith('.pyi'):

helper.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
from __future__ import print_function
2+
3+
import zipfile
24
from collections import defaultdict
35
import json
46
import os
@@ -19,6 +21,15 @@ def get_jsondoc_basepath():
1921
'api',
2022
)
2123

24+
def extract_jsondoc():
25+
zip_location = os.path.join(Application.getInstallationDirectory().getAbsolutePath(), "docs/GhidraAPI_javadoc.zip")
26+
extract_dir = os.path.join(
27+
Application.getUserCacheDirectory().getAbsolutePath(),
28+
'GhidraAPI_javadoc',
29+
Application.getApplicationVersion())
30+
31+
zip_file = zipfile.ZipFile(zip_location)
32+
zip_file.extractall(extract_dir)
2233

2334
def are_docs_available():
2435
return os.path.exists(get_jsondoc_basepath())

0 commit comments

Comments
 (0)