Skip to content

Commit

Permalink
issue_80 feedback corrections. All links converted into rst style lin…
Browse files Browse the repository at this point in the history
…ks .
  • Loading branch information
aryangoswami1205 committed Nov 20, 2024
1 parent bdb9b0f commit 1c6c651
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions scripts/create_processing_rst.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,16 +136,14 @@ def v3(alg: EnMAPProcessingAlgorithm, text, groupFolder, algoId):
# Title Section
title = alg.displayName()
title_text = f".. _{title}:\n\n{title}\n{'*' * len(title)}\n"
title_text = utilsConvertHtmlLinksToRstLinks(title_text) # Convert any HTML links
text = wrapAutoGenerated(title_text, "TITLE")

# Note: Add manually defined title-related content here if needed

# Description Section
description_text = injectGlossaryLinks(alg.shortDescription())
description_text = utilsConvertHtmlLinksToRstLinks(description_text) # Convert HTML links
text += wrapAutoGenerated(description_text, "DESCRIPTION")

# Note: Add manually defined description-related content here if needed

# Parameters Section
param_text = ''
outputsHeadingCreated = False
Expand All @@ -164,6 +162,7 @@ def v3(alg: EnMAPProcessingAlgorithm, text, groupFolder, algoId):

param_text += f'\n:guilabel:`{pd.description()}` [{pd.type()}]\n'
pdhelp = injectGlossaryLinks(pdhelp)
pdhelp = utilsConvertHtmlLinksToRstLinks(pdhelp) # Convert HTML links in help text
for line in pdhelp.split('\n'):
param_text += f' {line}\n'

Expand All @@ -177,13 +176,12 @@ def v3(alg: EnMAPProcessingAlgorithm, text, groupFolder, algoId):

text += wrapAutoGenerated(param_text, "PARAMETERS")

# Note: Add manually defined parameters-related content here if needed

# Command-line usage
algoId = 'enmapbox:' + alg.name()
result = subprocess.run(['qgis_process', 'help', algoId], stdout=subprocess.PIPE)
helptext = result.stdout.decode('cp1252')
helptext = helptext[helptext.find('----------------\nArguments\n----------------'):]
helptext = utilsConvertHtmlLinksToRstLinks(helptext) # Convert HTML links in usage text

usage_text = f"**Command-line usage**\n\n``>qgis_process help {algoId}``::\n\n"
usage_text += '\n'.join([f' {line}' for line in helptext.splitlines()])
Expand All @@ -193,6 +191,15 @@ def v3(alg: EnMAPProcessingAlgorithm, text, groupFolder, algoId):
return text


def utilsConvertHtmlLinksToRstLinks(text: str) -> str:
"""Convert all HTML-style links in the text to RST-style links."""
links = utilsFindHtmlWeblinks(text) # Find all HTML links in the text
for html_link in links:
rst_link = utilsHtmlWeblinkToRstWeblink(html_link)
text = text.replace(html_link, rst_link)
return text


def utilsFindHtmlWeblinks(text) -> List[str]:
match_: re.Match
starts = [match_.start() for match_ in re.finditer('<a href="', text)]
Expand Down

0 comments on commit 1c6c651

Please sign in to comment.