Skip to content

Conversation

@rzblue
Copy link
Member

@rzblue rzblue commented Dec 3, 2025

  • Only regenerate output when input changes. This fixes issues with autobuilders that trigger rebuilds on filesystem events
  • Use logging api instead of print. This makes the extension obey sphinx's verbosity settings
  • Use pathlib
  • use snake_case

- Only regenerate output when input changes. This fixes issues with autobuilders that trigger rebuilds on filesystem events
- Use logging api instead of print. This makes the extension obey sphinx's verbosity settings
- Use pathlib
- use snake_case
Comment on lines +74 to +100
with OUTPUT_FILE.open("w") as outf:
for source_file in source_files:
with source_file.open("r") as source:
if not debugJS:
# Minify each file independently - again, low bar solution for now
minified = jsmin(source.read())
outf.write(minified)
outf.write("\n")
else:
# Verbose, no minify, and add debug markers.
outf.write("\n\n\n")
outf.write(
"//*******************************************************\n"
)
outf.write(
"//*******************************************************\n"
)
outf.write("//** {}\n".format(source_file))
outf.write(
"//*******************************************************\n"
)
outf.write(
"//*******************************************************\n"
)
outf.write("\n")
outf.write(source.read())
outf.write("\n")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
with OUTPUT_FILE.open("w") as outf:
for source_file in source_files:
with source_file.open("r") as source:
if not debugJS:
# Minify each file independently - again, low bar solution for now
minified = jsmin(source.read())
outf.write(minified)
outf.write("\n")
else:
# Verbose, no minify, and add debug markers.
outf.write("\n\n\n")
outf.write(
"//*******************************************************\n"
)
outf.write(
"//*******************************************************\n"
)
outf.write("//** {}\n".format(source_file))
outf.write(
"//*******************************************************\n"
)
outf.write(
"//*******************************************************\n"
)
outf.write("\n")
outf.write(source.read())
outf.write("\n")
output_text = ""
for source_file in source_files:
text = ""
if not debugJS:
# Minify each file independently - again, low bar solution for now
minified = jsmin(source_file.read_text())
text += minified + "\n"
continue
# Verbose, no minify, and add debug markers.
text = f"""\n\n\n
//*******************************************************
//*******************************************************
//** {source_file}
//*******************************************************
//*******************************************************
{source_file.read_text()}
"""
output_text += textwrap.dedent(indented_string)
OUTPUT_FILE.write_text(output_text)

Further testing with dedent is needed, but I think it's more concise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants