Skip to content

Commit

Permalink
Merge pull request #3895 from masatake/I18NRubyGem
Browse files Browse the repository at this point in the history
I18nRubyGem: new parser

Close #3523
  • Loading branch information
masatake authored Dec 27, 2023
2 parents c0b2352 + bc3aa34 commit a8513a0
Show file tree
Hide file tree
Showing 57 changed files with 1,720 additions and 96 deletions.
15 changes: 10 additions & 5 deletions Tmain/extras-long.d/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,27 @@

CTAGS=$1

no_yaml()
{
grep -v I18nRubyGem
}

echo '# resetting'
${CTAGS} --quiet --options=NONE --with-list-header=no \
--extras='{subparser}' --list-extras
--extras='{subparser}' --list-extras | no_yaml

echo '# enabling 1'
${CTAGS} --quiet --options=NONE --with-list-header=no \
--extras=+'{pseudo}' --list-extras
--extras=+'{pseudo}' --list-extras | no_yaml

echo '# disabling 1'
${CTAGS} --quiet --options=NONE --with-list-header=no \
--extras=-'{fileScope}' --list-extras
--extras=-'{fileScope}' --list-extras | no_yaml

echo '# combination'
${CTAGS} --quiet --options=NONE --with-list-header=no \
--extras=-'{fileScope}+{inputFile}{reference}' --list-extras
--extras=-'{fileScope}+{inputFile}{reference}' --list-extras | no_yaml

echo '# combination with letters'
${CTAGS} --quiet --options=NONE --with-list-header=no \
--extras=-'{fileScope}+p{inputFile}q{reference}-f' --list-extras
--extras=-'{fileScope}+p{inputFile}q{reference}-f' --list-extras | no_yaml
11 changes: 8 additions & 3 deletions Tmain/list-extras.d/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@

CTAGS=$1

${CTAGS} --quiet --options=NONE --extras='*' --with-list-header --list-extras
${CTAGS} --quiet --options=NONE --extras='*' --with-list-header --machinable --list-extras
${CTAGS} --quiet --options=NONE --extras= --with-list-header --list-extras=NONE
no_yaml()
{
grep -v I18nRubyGem
}

${CTAGS} --quiet --options=NONE --extras='*' --with-list-header --list-extras | no_yaml
${CTAGS} --quiet --options=NONE --extras='*' --with-list-header --machinable --list-extras | no_yaml
${CTAGS} --quiet --options=NONE --extras= --with-list-header --list-extras=NONE | no_yaml
1 change: 1 addition & 0 deletions Tmain/list-subparsers-all.d/stdout-expected.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ DBusIntrospect XML base <> sub {bidirectional}
FunctionParameters Perl base <> sub {bidirectional}
GemSpec Ruby base <= sub {dedicated}
Glade XML base <> sub {bidirectional}
I18nRubyGem Yaml base <> sub {bidirectional}
IPythonCell Python base => sub {shared}
ITcl Tcl base <> sub {bidirectional}
Maven2 XML base <> sub {bidirectional}
Expand Down
3 changes: 3 additions & 0 deletions Units/parser-I18nRubyGem.r/language-force.d/args.ctags
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
--sort=no
--language-force=I18nRubyGem
--fields=+E
18 changes: 18 additions & 0 deletions Units/parser-I18nRubyGem.r/language-force.d/expected.tags
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
test input.i18n /^ test: 2$/;" k keyInMiddle:en extras:subparser
other input.i18n /^ other: 10$/;" k keyInMiddle:en extras:subparser
dog input.i18n /^ dog: dog$/;" k keyInMiddle:en.animals extras:subparser
cat input.i18n /^ cat: cat$/;" k keyInMiddle:en.animals extras:subparser
tracer input.i18n /^ tracer: tracer$/;" k keyInMiddle:en.tools extras:subparser
reporter input.i18n /^ reporter: reporter$/;" k keyInMiddle:en.tools extras:subparser
test input.i18n /^ test: 2$/;" k keyInMiddle:en extras:subparser,localeless
en.test input.i18n /^ test: 2$/;" k keyInMiddle:en extras:subparser,localeful
other input.i18n /^ other: 10$/;" k keyInMiddle:en extras:subparser,localeless
en.other input.i18n /^ other: 10$/;" k keyInMiddle:en extras:subparser,localeful
animals.dog input.i18n /^ dog: dog$/;" k keyInMiddle:en extras:subparser,localeless
en.animals.dog input.i18n /^ dog: dog$/;" k keyInMiddle:en.animals extras:subparser,localeful
animals.cat input.i18n /^ cat: cat$/;" k keyInMiddle:en extras:subparser,localeless
en.animals.cat input.i18n /^ cat: cat$/;" k keyInMiddle:en.animals extras:subparser,localeful
tools.tracer input.i18n /^ tracer: tracer$/;" k keyInMiddle:en extras:subparser,localeless
en.tools.tracer input.i18n /^ tracer: tracer$/;" k keyInMiddle:en.tools extras:subparser,localeful
tools.reporter input.i18n /^ reporter: reporter$/;" k keyInMiddle:en extras:subparser,localeless
en.tools.reporter input.i18n /^ reporter: reporter$/;" k keyInMiddle:en.tools extras:subparser,localeful
1 change: 1 addition & 0 deletions Units/parser-I18nRubyGem.r/language-force.d/features
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
yaml
10 changes: 10 additions & 0 deletions Units/parser-I18nRubyGem.r/language-force.d/input.i18n
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
en:
test: 2
other: 10
animals:
dog: dog
cat: cat
tools:
tracer: tracer
reporter: reporter
2 changes: 2 additions & 0 deletions Units/parser-I18nRubyGem.r/no-language-force.d/args.ctags
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--sort=no
--fields=+E
21 changes: 21 additions & 0 deletions Units/parser-I18nRubyGem.r/no-language-force.d/expected.tags
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
test input.yml /^ test: 2$/;" k keyInMiddle:en extras:subparser
other input.yml /^ other: 10$/;" k keyInMiddle:en extras:subparser
dog input.yml /^ dog: dog$/;" k keyInMiddle:en.animals extras:subparser
cat input.yml /^ cat: cat$/;" k keyInMiddle:en.animals extras:subparser
tracer input.yml /^ tracer: tracer$/;" k keyInMiddle:en.tools extras:subparser
reporter input.yml /^ reporter: reporter$/;" k keyInMiddle:en.tools extras:subparser
test input.yml /^ test: 2$/;" k keyInMiddle:en extras:subparser,localeless
en.test input.yml /^ test: 2$/;" k keyInMiddle:en extras:subparser,localeful
other input.yml /^ other: 10$/;" k keyInMiddle:en extras:subparser,localeless
en.other input.yml /^ other: 10$/;" k keyInMiddle:en extras:subparser,localeful
animals.dog input.yml /^ dog: dog$/;" k keyInMiddle:en extras:subparser,localeless
en.animals.dog input.yml /^ dog: dog$/;" k keyInMiddle:en.animals extras:subparser,localeful
animals.cat input.yml /^ cat: cat$/;" k keyInMiddle:en extras:subparser,localeless
en.animals.cat input.yml /^ cat: cat$/;" k keyInMiddle:en.animals extras:subparser,localeful
tools.tracer input.yml /^ tracer: tracer$/;" k keyInMiddle:en extras:subparser,localeless
en.tools.tracer input.yml /^ tracer: tracer$/;" k keyInMiddle:en.tools extras:subparser,localeful
tools.reporter input.yml /^ reporter: reporter$/;" k keyInMiddle:en extras:subparser,localeless
en.tools.reporter input.yml /^ reporter: reporter$/;" k keyInMiddle:en.tools extras:subparser,localeful
hello input-0.yml /^ hello: hello$/;" k keyInMiddle:en extras:subparser
hello input-0.yml /^ hello: hello$/;" k keyInMiddle:en extras:subparser,localeless
en.hello input-0.yml /^ hello: hello$/;" k keyInMiddle:en extras:subparser,localeful
1 change: 1 addition & 0 deletions Units/parser-I18nRubyGem.r/no-language-force.d/features
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
yaml
3 changes: 3 additions & 0 deletions Units/parser-I18nRubyGem.r/no-language-force.d/input-0.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
en:
hello: hello
10 changes: 10 additions & 0 deletions Units/parser-I18nRubyGem.r/no-language-force.d/input.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
en:
test: 2
other: 10
animals:
dog: dog
cat: cat
tools:
tracer: tracer
reporter: reporter
2 changes: 2 additions & 0 deletions Units/parser-I18nRubyGem.r/no-locale.d/args.ctags
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--sort=no
--fields=+E
3 changes: 3 additions & 0 deletions Units/parser-I18nRubyGem.r/no-locale.d/expected.tags
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
hello input-0.yml /^ hello: hello$/;" k keyInMiddle:en extras:subparser
hello input-0.yml /^ hello: hello$/;" k keyInMiddle:en extras:subparser,localeless
en.hello input-0.yml /^ hello: hello$/;" k keyInMiddle:en extras:subparser,localeful
1 change: 1 addition & 0 deletions Units/parser-I18nRubyGem.r/no-locale.d/features
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
yaml
3 changes: 3 additions & 0 deletions Units/parser-I18nRubyGem.r/no-locale.d/input-0.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
en:
hello: hello
10 changes: 10 additions & 0 deletions Units/parser-I18nRubyGem.r/no-locale.d/input.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
nosuchlocale:
test: 2
other: 10
animals:
dog: dog
cat: cat
tools:
tracer: tracer
reporter: reporter
5 changes: 5 additions & 0 deletions Units/parser-I18nRubyGem.r/qualified.d/args.ctags
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
--sort=no
--language-force=I18nRubyGem
--fields=+E
--extras=+q
--extras-I18nRubyGem=-{localeful}
21 changes: 21 additions & 0 deletions Units/parser-I18nRubyGem.r/qualified.d/expected.tags
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
test input.yml /^ test: 2$/;" k keyInMiddle:en extras:subparser
en.test input.yml /^ test: 2$/;" k keyInMiddle:en extras:qualified,subparser
other input.yml /^ other: 10$/;" k keyInMiddle:en extras:subparser
en.other input.yml /^ other: 10$/;" k keyInMiddle:en extras:qualified,subparser
dog input.yml /^ dog: dog$/;" k keyInMiddle:en.animals extras:subparser
en.animals.dog input.yml /^ dog: dog$/;" k keyInMiddle:en.animals extras:qualified,subparser
cat input.yml /^ cat: cat$/;" k keyInMiddle:en.animals extras:subparser
en.animals.cat input.yml /^ cat: cat$/;" k keyInMiddle:en.animals extras:qualified,subparser
tracer input.yml /^ tracer: tracer$/;" k keyInMiddle:en.tools extras:subparser
en.tools.tracer input.yml /^ tracer: tracer$/;" k keyInMiddle:en.tools extras:qualified,subparser
reporter input.yml /^ reporter: reporter$/;" k keyInMiddle:en.tools extras:subparser
en.tools.reporter input.yml /^ reporter: reporter$/;" k keyInMiddle:en.tools extras:qualified,subparser
test input.yml /^ test: 2$/;" k keyInMiddle:en extras:subparser,localeless
other input.yml /^ other: 10$/;" k keyInMiddle:en extras:subparser,localeless
animals.dog input.yml /^ dog: dog$/;" k keyInMiddle:en extras:subparser,localeless
animals.cat input.yml /^ cat: cat$/;" k keyInMiddle:en extras:subparser,localeless
tools.tracer input.yml /^ tracer: tracer$/;" k keyInMiddle:en extras:subparser,localeless
tools.reporter input.yml /^ reporter: reporter$/;" k keyInMiddle:en extras:subparser,localeless
hello input-0.yml /^ hello: hello$/;" k keyInMiddle:en extras:subparser
en.hello input-0.yml /^ hello: hello$/;" k keyInMiddle:en extras:qualified,subparser
hello input-0.yml /^ hello: hello$/;" k keyInMiddle:en extras:subparser,localeless
1 change: 1 addition & 0 deletions Units/parser-I18nRubyGem.r/qualified.d/features
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
yaml
3 changes: 3 additions & 0 deletions Units/parser-I18nRubyGem.r/qualified.d/input-0.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
en:
hello: hello
10 changes: 10 additions & 0 deletions Units/parser-I18nRubyGem.r/qualified.d/input.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
en:
test: 2
other: 10
animals:
dog: dog
cat: cat
tools:
tracer: tracer
reporter: reporter
3 changes: 3 additions & 0 deletions Units/parser-I18nRubyGem.r/simple-I18nRubyGem.d/args.ctags
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
--sort=no
--language-force=I18nRubyGem
--fields=+E
21 changes: 21 additions & 0 deletions Units/parser-I18nRubyGem.r/simple-I18nRubyGem.d/expected.tags
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
test input.yml /^ test: 2$/;" k keyInMiddle:en extras:subparser
other input.yml /^ other: 10$/;" k keyInMiddle:en extras:subparser
dog input.yml /^ dog: dog$/;" k keyInMiddle:en.animals extras:subparser
cat input.yml /^ cat: cat$/;" k keyInMiddle:en.animals extras:subparser
tracer input.yml /^ tracer: tracer$/;" k keyInMiddle:en.tools extras:subparser
reporter input.yml /^ reporter: reporter$/;" k keyInMiddle:en.tools extras:subparser
test input.yml /^ test: 2$/;" k keyInMiddle:en extras:subparser,localeless
en.test input.yml /^ test: 2$/;" k keyInMiddle:en extras:subparser,localeful
other input.yml /^ other: 10$/;" k keyInMiddle:en extras:subparser,localeless
en.other input.yml /^ other: 10$/;" k keyInMiddle:en extras:subparser,localeful
animals.dog input.yml /^ dog: dog$/;" k keyInMiddle:en extras:subparser,localeless
en.animals.dog input.yml /^ dog: dog$/;" k keyInMiddle:en.animals extras:subparser,localeful
animals.cat input.yml /^ cat: cat$/;" k keyInMiddle:en extras:subparser,localeless
en.animals.cat input.yml /^ cat: cat$/;" k keyInMiddle:en.animals extras:subparser,localeful
tools.tracer input.yml /^ tracer: tracer$/;" k keyInMiddle:en extras:subparser,localeless
en.tools.tracer input.yml /^ tracer: tracer$/;" k keyInMiddle:en.tools extras:subparser,localeful
tools.reporter input.yml /^ reporter: reporter$/;" k keyInMiddle:en extras:subparser,localeless
en.tools.reporter input.yml /^ reporter: reporter$/;" k keyInMiddle:en.tools extras:subparser,localeful
hello input-0.yml /^ hello: hello$/;" k keyInMiddle:en extras:subparser
hello input-0.yml /^ hello: hello$/;" k keyInMiddle:en extras:subparser,localeless
en.hello input-0.yml /^ hello: hello$/;" k keyInMiddle:en extras:subparser,localeful
1 change: 1 addition & 0 deletions Units/parser-I18nRubyGem.r/simple-I18nRubyGem.d/features
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
yaml
3 changes: 3 additions & 0 deletions Units/parser-I18nRubyGem.r/simple-I18nRubyGem.d/input-0.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
en:
hello: hello
10 changes: 10 additions & 0 deletions Units/parser-I18nRubyGem.r/simple-I18nRubyGem.d/input.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
en:
test: 2
other: 10
animals:
dog: dog
cat: cat
tools:
tracer: tracer
reporter: reporter
1 change: 1 addition & 0 deletions docs/man-pages.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Man pages
ctags-lang-elm(7) <man/ctags-lang-elm.7.rst>
ctags-lang-fortran(7) <man/ctags-lang-fortran.7.rst>
ctags-lang-gdscript(7) <man/ctags-lang-gdscript.7.rst>
ctags-lang-i18nrubygem(7) <man/ctags-lang-i18nrubygem.7.rst>
ctags-lang-iPythonCell(7) <man/ctags-lang-iPythonCell.7.rst>
ctags-lang-inko(7) <man/ctags-lang-inko.7.rst>
ctags-lang-javascript(7) <man/ctags-lang-javascript.7.rst>
Expand Down
83 changes: 83 additions & 0 deletions docs/man/ctags-lang-i18nrubygem.7.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
.. _ctags-lang-i18nrubgem(7):

==============================================================
ctags-lang-i18nrubgem
==============================================================

Random notes about tagging input for I18n Ruby Gem with Universal Ctags

:Version: 6.0.0
:Manual group: Universal Ctags
:Manual section: 7

SYNOPSIS
--------
| **ctags** ... --extras=+s --languages=+I18nRubyGem ...
| **ctags** ... --extras=+s --language-force=I18nRubyGem ...
| **ctags** ... --extras=+s --map-I18nRubyGem=+.yaml ...
| **ctags** ... --extras=+s --map-I18nRubyGem=+.yml ...
DESCRIPTION
-----------
This man page gathers random notes about tagging input for I18n Ruby
Gem [RUBYI18N]_. I18nRubyGem is a subparser running on Yaml parser. If a
top-level scalar token of a given Yaml source input is a local name [ISOCODES]_,
I18nRubyGem activates itself. If not, I18nRubyGem does nothing.

"input.yaml"

.. code-block:: YAML
---
ja:
msg:
error: エラー
function: 関数
"output.tags"
with "--options=NONE -o - --fields=+E input.yaml"

.. code-block:: tags
error input.yaml /^ error: エラー$/;" k keyInMiddle:ja.msg extras:subparser
function input.yaml /^ function: 関数$/;" k keyInMiddle:ja.msg extras:subparser
ja.msg.error input.yaml /^ error: エラー$/;" k keyInMiddle:ja.msg extras:subparser,localeful
ja.msg.function input.yaml /^ function: 関数$/;" k keyInMiddle:ja.msg extras:subparser,localeful
msg.error input.yaml /^ error: エラー$/;" k keyInMiddle:ja extras:subparser,localeless
msg.function input.yaml /^ function: 関数$/;" k keyInMiddle:ja extras:subparser,localeless
With the options, the parser emits three tag entries for a key:
"error", "js.msg.error", and "msg.error" for the key "error", The
parser emits "error" at the first line always.

To emit "ja.msg.error", a ``localeful`` extra tag, at the fifth line
always. If you specify ``--extra=+q`` or ``--extra=+{qualified}``,
ctags emits the same tag twice: a ``localeful`` tag, and a ``qualified`` tag.
You can suppress the ``localeful`` extra tags., specify
``--extras-I18nRubyGem=-{localeful}``.

To emit "msg.error", a ``localeless`` extra tag, at the fifth line
always. The parser creates a ``localeless`` extra tag by truncating
the first component (e.g. "ja.") from the associated full qualified
extra tag (e.g. "ja.msg.error"). ``localeless`` extra is enabled by
default. If you don't need ``localeless`` extra tags, specify
``--extras-I18nRubyGem=-{localeless}``.

The parser doesn't make tag entries for top-level and mid-level components like
``ja`` and ``msg`` by default. If you need them, specify
``--kinds-I18nRubyGem=+{keyInMiddle}``.

KNOWN BUGS
----------
The mechanism activating I18nRubyGem subparser doesn't work well for YAML
source input containing multiple documents.

SEE ALSO
--------
:ref:`ctags(1) <ctags(1)>`

REFERENCES
----------
.. [RUBYI18N] Ruby I18n, https://github.com/ruby-i18n/i18n
.. [ISOCODES] iso-codes, https://salsa.debian.org/iso-codes-team/iso-codes
1 change: 1 addition & 0 deletions docs/news/HEAD.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ The following parsers have been added:
* TerraformVariables *optlib* by masatake · Pull Request #3684

* PkgConfig *optlib*: new parser
* I18nRubyGem *YAML based subparser* · Close #3533

Changes about parser specific kinds, roles, fields, and extras
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
Loading

0 comments on commit a8513a0

Please sign in to comment.