Skip to content

Commit

Permalink
fix ref doc
Browse files Browse the repository at this point in the history
  • Loading branch information
wangzelin007 committed Jul 12, 2023
1 parent dba8296 commit a7315f3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
13 changes: 10 additions & 3 deletions scripts/ci/index_ref_doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,24 +51,31 @@
class TestIndexRefDocsMeta(type):
def __new__(mcs, name, bases, _dict):

def gen_test(ext_name, ext_url, filename):
def gen_test(ext_name, ext_url, filename, dep_url):
def test(self):
if dep_url.get(ext_name):
dep_file = get_whl_from_url(dep_url[ext_name][0], dep_url[ext_name][1], self.whl_dir)
else:
dep_file = ''
ext_file = get_whl_from_url(ext_url, filename, self.whl_dir)
ref_doc_out_dir = os.path.join(REF_DOC_OUT_DIR, ext_name)
if not os.path.isdir(ref_doc_out_dir):
os.mkdir(ref_doc_out_dir)
script_args = [sys.executable, REF_GEN_SCRIPT, '--extension-file', ext_file, '--output-dir',
ref_doc_out_dir]
ref_doc_out_dir, '--dependent-file', dep_file]
try:
check_call(script_args)
except CalledProcessError as e:
traceback.print_exc()
raise e
return test

dep_url = {}
for ext_name, ext_url, filename in ALL_TESTS:
test_name = "test_ref_doc_%s" % ext_name
_dict[test_name] = gen_test(ext_name, ext_url, filename)
if ext_name == 'containerapp':
dep_url['containerapp-preview'] = [ext_url, filename]
_dict[test_name] = gen_test(ext_name, ext_url, filename, dep_url)
return type.__new__(mcs, name, bases, _dict)


Expand Down
13 changes: 10 additions & 3 deletions scripts/refdoc/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,20 @@ def print_status(msg=''):
print('-- '+msg)


def generate(ext_file, output_dir):
def generate(ext_file, output_dir, dep_file):
# Verify sphinx installed in environment before we get started
check_call(['sphinx-build', '--version'])
if not output_dir:
output_dir = tempfile.mkdtemp(prefix='ref-doc-out-', dir=os.getcwd())
print_status('Using output directory {}'.format(output_dir))
temp_extension_dir = tempfile.mkdtemp()
try:
if dep_file:
pip_cmd = [sys.executable, '-m', 'pip', 'install', '--target',
os.path.join(temp_extension_dir, 'extension'),
dep_file, '--disable-pip-version-check', '--no-cache-dir']
print_status('Executing "{}"'.format(' '.join(pip_cmd)))
check_call(pip_cmd)
pip_cmd = [sys.executable, '-m', 'pip', 'install', '--target', os.path.join(temp_extension_dir, 'extension'),
ext_file, '--disable-pip-version-check', '--no-cache-dir']
print_status('Executing "{}"'.format(' '.join(pip_cmd)))
Expand Down Expand Up @@ -75,6 +81,7 @@ def _type_path(val):
help='Path to the extension .whl file.', required=True, type=_type_ext_file)
parser.add_argument('-o', '--output-dir', dest='output_dir',
help='Path to place the generated documentation. By default, a temporary directory will be created.', required=False, type=_type_path)

parser.add_argument('-d', '--dependent-file', dest='dep_file',
help='Path to the dependent extension .whl file.', required=True, type=str)
args = parser.parse_args()
generate(args.ext_file, args.output_dir)
generate(args.ext_file, args.output_dir, args.dep_file)

0 comments on commit a7315f3

Please sign in to comment.