From 70b46b58cc91057e6d1328ff1e82bc4622a6e363 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Wed, 13 Aug 2025 13:14:21 +0900 Subject: [PATCH 1/3] [DOC] Enclose English in quotes --- README.md | 2 +- lib/English.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b72c584..70d39ec 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ $\ = ' -- ' print $', $$, "\n" ``` -With English: +With 'English': ```ruby require "English" diff --git a/lib/English.rb b/lib/English.rb index 03fe721..1553c0b 100644 --- a/lib/English.rb +++ b/lib/English.rb @@ -9,7 +9,7 @@ # "waterbuffalo" =~ /buff/ # print $', $$, "\n" # -# With English: +# With 'English': # # require "English" # From c389e01aeabf070f41077922a1a37599a2d3f96b Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Wed, 13 Aug 2025 13:18:25 +0900 Subject: [PATCH 2/3] [DOC] Markup variables in the README.md table as code --- README.md | 104 ++++++++++++++--------------- Rakefile | 5 +- bin/alias_markdown_table_generator | 18 ++--- 3 files changed, 64 insertions(+), 63 deletions(-) diff --git a/README.md b/README.md index 70d39ec..032ad0f 100644 --- a/README.md +++ b/README.md @@ -44,62 +44,62 @@ The aliases are defined in [English.rb](lib/English.rb), and are as follows, fir ### Builtin to Alias Table -| Builtin | Alias | -| :-----: | ------------------------ | -| $! | $ERROR_INFO | -| $$ | $PID | -| $$ | $PROCESS_ID | -| $& | $MATCH | -| $' | $POSTMATCH | -| $* | $ARGV | -| $+ | $LAST_PAREN_MATCH | -| $, | $OFS | -| $, | $OUTPUT_FIELD_SEPARATOR | -| $. | $INPUT_LINE_NUMBER | -| $. | $NR | -| $/ | $INPUT_RECORD_SEPARATOR | -| $/ | $RS | -| $; | $FIELD_SEPARATOR | -| $; | $FS | -| $< | $DEFAULT_INPUT | -| $> | $DEFAULT_OUTPUT | -| $? | $CHILD_STATUS | -| $@ | $ERROR_POSITION | -| $\ | $ORS | -| $\ | $OUTPUT_RECORD_SEPARATOR | -| $_ | $LAST_READ_LINE | -| $` | $PREMATCH | -| $~ | $LAST_MATCH_INFO | +| Builtin | Alias | +| :------: | -------------------------- | +| `` $! `` | `$ERROR_INFO` | +| `` $$ `` | `$PID` | +| `` $$ `` | `$PROCESS_ID` | +| `` $& `` | `$MATCH` | +| `` $' `` | `$POSTMATCH` | +| `` $* `` | `$ARGV` | +| `` $+ `` | `$LAST_PAREN_MATCH` | +| `` $, `` | `$OFS` | +| `` $, `` | `$OUTPUT_FIELD_SEPARATOR` | +| `` $. `` | `$INPUT_LINE_NUMBER` | +| `` $. `` | `$NR` | +| `` $/ `` | `$INPUT_RECORD_SEPARATOR` | +| `` $/ `` | `$RS` | +| `` $; `` | `$FIELD_SEPARATOR` | +| `` $; `` | `$FS` | +| `` $< `` | `$DEFAULT_INPUT` | +| `` $> `` | `$DEFAULT_OUTPUT` | +| `` $? `` | `$CHILD_STATUS` | +| `` $@ `` | `$ERROR_POSITION` | +| `` $\ `` | `$ORS` | +| `` $\ `` | `$OUTPUT_RECORD_SEPARATOR` | +| `` $_ `` | `$LAST_READ_LINE` | +| `` $` `` | `$PREMATCH` | +| `` $~ `` | `$LAST_MATCH_INFO` | ### Alias to Builtin Table -| Alias | Builtin | -| ------------------------ | :-----: | -| $ARGV | $* | -| $CHILD_STATUS | $? | -| $DEFAULT_INPUT | $< | -| $DEFAULT_OUTPUT | $> | -| $ERROR_INFO | $! | -| $ERROR_POSITION | $@ | -| $FIELD_SEPARATOR | $; | -| $FS | $; | -| $INPUT_LINE_NUMBER | $. | -| $INPUT_RECORD_SEPARATOR | $/ | -| $LAST_MATCH_INFO | $~ | -| $LAST_PAREN_MATCH | $+ | -| $LAST_READ_LINE | $_ | -| $MATCH | $& | -| $NR | $. | -| $OFS | $, | -| $ORS | $\ | -| $OUTPUT_FIELD_SEPARATOR | $, | -| $OUTPUT_RECORD_SEPARATOR | $\ | -| $PID | $$ | -| $POSTMATCH | $' | -| $PREMATCH | $` | -| $PROCESS_ID | $$ | -| $RS | $/ | +| Alias | Builtin | +| -------------------------- | :------: | +| `$ARGV` | `` $* `` | +| `$CHILD_STATUS` | `` $? `` | +| `$DEFAULT_INPUT` | `` $< `` | +| `$DEFAULT_OUTPUT` | `` $> `` | +| `$ERROR_INFO` | `` $! `` | +| `$ERROR_POSITION` | `` $@ `` | +| `$FIELD_SEPARATOR` | `` $; `` | +| `$FS` | `` $; `` | +| `$INPUT_LINE_NUMBER` | `` $. `` | +| `$INPUT_RECORD_SEPARATOR` | `` $/ `` | +| `$LAST_MATCH_INFO` | `` $~ `` | +| `$LAST_PAREN_MATCH` | `` $+ `` | +| `$LAST_READ_LINE` | `` $_ `` | +| `$MATCH` | `` $& `` | +| `$NR` | `` $. `` | +| `$OFS` | `` $, `` | +| `$ORS` | `` $\ `` | +| `$OUTPUT_FIELD_SEPARATOR` | `` $, `` | +| `$OUTPUT_RECORD_SEPARATOR` | `` $\ `` | +| `$PID` | `` $$ `` | +| `$POSTMATCH` | `` $' `` | +| `$PREMATCH` | `` $` `` | +| `$PROCESS_ID` | `` $$ `` | +| `$RS` | `` $/ `` | ## Development diff --git a/Rakefile b/Rakefile index fa19701..fe27e7f 100644 --- a/Rakefile +++ b/Rakefile @@ -1,5 +1,6 @@ require "bundler/gem_tasks" -file "README.md" => "lib/English.rb" do - ruby "bin/alias_markdown_table_generator", "README.md" +generator = "bin/alias_markdown_table_generator" +file "README.md" => ["lib/English.rb", generator] do + ruby generator, "README.md" end diff --git a/bin/alias_markdown_table_generator b/bin/alias_markdown_table_generator index 7fc8dc6..46809cd 100755 --- a/bin/alias_markdown_table_generator +++ b/bin/alias_markdown_table_generator @@ -6,15 +6,15 @@ # # | Alias | Built-In | # | ------------------------ | :------: | -# | $ARGV | $* | -# | $CHILD_STATUS | $? | +# | `$ARGV` | `` $* `` | +# | `$CHILD_STATUS` | `` $? `` | # # and: # # | Built-In | Alias | -# | -------- | :----------------------: | -# | $* | $ARGV | -# | $? | $CHILD_STATUS | +# | :------: | ------------------------ | +# | `` $* `` | `$ARGV` | +# | `` $? `` | `$CHILD_STATUS` | # # Some of the formatting done here is not necessary, but is done to make the generated markdown more readable. @@ -25,7 +25,7 @@ class FileParser ALIAS_SOURCE_FILESPEC = File.join(__dir__, '../lib/English.rb') def self.parse(code_text_lines=File.readlines(ALIAS_SOURCE_FILESPEC)) - code_text_lines.grep(/^\s*alias\s+(\S+)\s+(\S+)/) {$~.captures} + code_text_lines.grep(/^\s*alias\s+(\S+)\s+(\S+)/) {["`#$1`", "`` #$2 ``"]} end end @@ -95,12 +95,12 @@ if __FILE__ == $0 if replace case line when /^##?\s/, /^### (?!Alias to Builtin Table)/ - puts line replace = false + else + next end - else - puts line end + puts line end end end From 5e60c1068ad7cee364692a666ecfed7de96b7338 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Wed, 13 Aug 2025 13:20:21 +0900 Subject: [PATCH 3/3] [DOC] Markup variables in the full list as code --- Rakefile | 3 +++ bin/alias_list_update.rb | 8 +++++++ lib/English.rb | 48 ++++++++++++++++++++-------------------- 3 files changed, 35 insertions(+), 24 deletions(-) create mode 100755 bin/alias_list_update.rb diff --git a/Rakefile b/Rakefile index fe27e7f..4f7be77 100644 --- a/Rakefile +++ b/Rakefile @@ -4,3 +4,6 @@ generator = "bin/alias_markdown_table_generator" file "README.md" => ["lib/English.rb", generator] do ruby generator, "README.md" end +task "update-alias-table" do + ruby "-i", "bin/alias_list_update.rb", "lib/English.rb" +end diff --git a/bin/alias_list_update.rb b/bin/alias_list_update.rb new file mode 100755 index 0000000..dbd4512 --- /dev/null +++ b/bin/alias_list_update.rb @@ -0,0 +1,8 @@ +#!ruby +content = ARGF.file.read +list = content.scan(/^alias (\$\S+)( +)(\$.)$/).map do |a, s, b| + "# #{a}::#{s}#{b}\n" +end +puts content.sub(/^# *Below is a full list.*(?:\n# *\S.*)*\n#\n\K(?:# .*\n)*/) { + list.join("") +} diff --git a/lib/English.rb b/lib/English.rb index 1553c0b..bf7896d 100644 --- a/lib/English.rb +++ b/lib/English.rb @@ -20,30 +20,30 @@ # Below is a full list of descriptive aliases and their associated global # variable: # -# $ERROR_INFO:: $! -# $ERROR_POSITION:: $@ -# $FS:: $; -# $FIELD_SEPARATOR:: $; -# $OFS:: $, -# $OUTPUT_FIELD_SEPARATOR:: $, -# $RS:: $/ -# $INPUT_RECORD_SEPARATOR:: $/ -# $ORS:: $\ -# $OUTPUT_RECORD_SEPARATOR:: $\ -# $INPUT_LINE_NUMBER:: $. -# $NR:: $. -# $LAST_READ_LINE:: $_ -# $DEFAULT_OUTPUT:: $> -# $DEFAULT_INPUT:: $< -# $PID:: $$ -# $PROCESS_ID:: $$ -# $CHILD_STATUS:: $? -# $LAST_MATCH_INFO:: $~ -# $ARGV:: $* -# $MATCH:: $& -# $PREMATCH:: $` -# $POSTMATCH:: $' -# $LAST_PAREN_MATCH:: $+ +# $ERROR_INFO:: $! +# $ERROR_POSITION:: $@ +# $FS:: $; +# $FIELD_SEPARATOR:: $; +# $OFS:: $, +# $OUTPUT_FIELD_SEPARATOR:: $, +# $RS:: $/ +# $INPUT_RECORD_SEPARATOR:: $/ +# $ORS:: $\ +# $OUTPUT_RECORD_SEPARATOR:: $\ +# $NR:: $. +# $INPUT_LINE_NUMBER:: $. +# $LAST_READ_LINE:: $_ +# $DEFAULT_OUTPUT:: $> +# $DEFAULT_INPUT:: $< +# $PID:: $$ +# $PROCESS_ID:: $$ +# $CHILD_STATUS:: $? +# $LAST_MATCH_INFO:: $~ +# $ARGV:: $* +# $MATCH:: $& +# $PREMATCH:: $` +# $POSTMATCH:: $' +# $LAST_PAREN_MATCH:: $+ # module English end if false