alamb commented on code in PR #19254:
URL: https://github.com/apache/datafusion/pull/19254#discussion_r2606307560


##########
ci/scripts/doc_prettier_check.sh:
##########
@@ -0,0 +1,43 @@
+#!/usr/bin/env bash
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+SCRIPT_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/$(basename 
"${BASH_SOURCE[0]}")"
+echo "$SCRIPT_PATH: Checking document format with prettier"
+
+# Ensure `npx` is available
+if ! command -v npx >/dev/null 2>&1; then
+  echo "npx is required to run the prettier check. Install Node.js (e.g., brew 
install node) and re-run." >&2
+  exit 1
+fi
+ 
+# if you encounter error, change '--check' to '--write' in the below command, 
and

Review Comment:
   I tested this out locally and it worked great for me:
   
   ```
   $ ./ci/scripts/doc_prettier_check.sh
   /Users/andrewlamb/Software/datafusion/ci/scripts/doc_prettier_check.sh: 
Checking document format with prettier
   Checking formatting...
   [warn] docs/source/library-user-guide/upgrading.md
   [warn] Code style issues found in the above file. Forgot to run Prettier?
   ./ci/scripts/doc_prettier_check.sh: line 41: prettier: command not found
   Prettier check failed. To fix, rerun  with --write (change --check to 
--write in the script), commit the formatted files, and re-run the check.
   ```
   
   I think it would be even nicer / better if it could also make the changes as 
well (so people don't have to do a second step to update the prettier docs)
   
   For example, if the check fails, maybe it could automatically re-run 
prettier with `--write`
   
   
   Or maybe the script could accept a `--write` command to get it to write?
   
   
   ```shell
   $ ./ci/scripts/doc_prettier_check.sh --write
   ```



##########
.github/workflows/dev.yml:
##########
@@ -48,16 +48,8 @@ jobs:
         with:
           node-version: "20"
       - name: Prettier check
-        run: |
-          # if you encounter error, rerun the command below and commit the 
changes
-          #
-          # ignore subproject CHANGELOG.md because they are machine generated
-          npx [email protected] --write \
-            '{datafusion,datafusion-cli,datafusion-examples,dev,docs}/**/*.md' 
\
-            '!datafusion/CHANGELOG.md' \
-            README.md \
-            CONTRIBUTING.md
-          git diff --exit-code
+      # if you encounter error, see instructions inside the script

Review Comment:
   👍 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to