diff --git a/dev-support/ci/xml_to_md.py b/dev-support/ci/xml_to_md.py index 54e885c28337..a059e00672c8 100644 --- a/dev-support/ci/xml_to_md.py +++ b/dev-support/ci/xml_to_md.py @@ -31,7 +31,7 @@ def extract_xml_from_jar(jar_path, xml_filename): xml_files = [] with zipfile.ZipFile(jar_path, 'r') as jar: for file_info in jar.infolist(): - if file_info.filename.endswith(xml_filename): + if file_info.filename.endswith(xml_filename) and 'network-topology-default.xml' != file_info.filename: with jar.open(file_info.filename) as xml_file: xml_files.append(xml_file.read()) return xml_files @@ -65,8 +65,8 @@ def parse_xml_file(xml_content, properties): tag = prop.findtext('tag', '') properties[name] = Property( - name=name, - value=prop.findtext('value', ''), + name=name.strip(), + value=prop.findtext('value', '').strip(), tag=tag, description=' '.join(description.split()).strip() ) @@ -107,13 +107,19 @@ def generate_markdown(properties): """ placeholder_pattern = re.compile(r'(\$)?\{([^}]+)\}') + multi_space_pattern = re.compile(r' +') for prop in sorted(properties.values(), key=lambda p: p.name): # Escape pipe characters and wrap {placeholders} in backticks description = prop.description.replace('|', '\\|') description = placeholder_pattern.sub(r'`\1{\2}`', description) - value = prop.value.replace('|', '\\|') if prop.value else '' - value = placeholder_pattern.sub(r'`\1{\2}`', value) if value else '' + + value = prop.value + if value: + value = value.replace('|', '\\|') + value = placeholder_pattern.sub(r'`\1{\2}`', value) + value = value.replace('\n', ' ') + value = multi_space_pattern.sub(' ', value) markdown += f"| `{prop.name}` | {value} | {prop.tag} | {description} |\n" @@ -137,11 +143,13 @@ def main(): raise ValueError("SNAPSHOT directory not found in the specified base path.") extract_path = os.path.join(snapshot_dir, 'share', 'ozone', 'lib') - xml_filename = 'ozone-default.xml' + xml_filename = '-default.xml' property_map = {} for file_name in os.listdir(extract_path): - if file_name.startswith('hdds-common-') and file_name.endswith('.jar'): + if (file_name.startswith('hdds-') or file_name.startswith('ozone-')) \ + and not file_name.startswith('ozone-filesystem-hadoop') \ + and file_name.endswith('.jar'): jar_path = os.path.join(extract_path, file_name) xml_contents = extract_xml_from_jar(jar_path, xml_filename) for xml_content in xml_contents: