Skip to content

Experimental command to format code blocks embedded in docstrings #7598

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 25 commits into from
Jul 9, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
better approach than a new env variable
  • Loading branch information
zth committed Jul 9, 2025
commit 02eb87b67d91c7f6a1da09e5cb08e30ba08198eb
2 changes: 1 addition & 1 deletion tests/tools_tests/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ done
# Test format-docstrings command
for file in src/docstrings-format/*.{res,resi}; do
output="src/expected/$(basename $file).expected"
DISABLE_COLOR=true ../../_build/install/default/bin/rescript-tools format-docstrings "$file" --stdout > $output
../../_build/install/default/bin/rescript-tools format-docstrings "$file" --stdout > $output
# # CI. We use LF, and the CI OCaml fork prints CRLF. Convert.
if [ "$RUNNER_OS" == "Windows" ]; then
perl -pi -e 's/\r\n/\n/g' -- $output
Expand Down
6 changes: 1 addition & 5 deletions tools/bin/main.ml
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,10 @@ let main () =
logAndExit (Tools.extractDocs ~entryPointFile:path ~debug:false)
| _ -> logAndExit (Error docHelp))
| "format-docstrings" :: rest -> (
(try
match Sys.getenv "DISABLE_COLOR" with
| "true" -> Clflags.color := Some Misc.Color.Never
| _ -> ()
with Not_found -> ());
match rest with
| ["-h"] | ["--help"] -> logAndExit (Ok formatDocstringsHelp)
| [path; "--stdout"] -> (
Clflags.color := Some Misc.Color.Never;
match
Tools.FormatDocstrings.formatDocstrings ~outputMode:`Stdout
~entryPointFile:path
Expand Down