mquinson / po4a

Maintain the translations of your documentation with ease (PO for anything)
http://po4a.org/
GNU General Public License v2.0
123 stars 61 forks source link

[Yaml] add option to parse only specific Yaml paths #331

Closed oliverrahner closed 2 years ago

oliverrahner commented 2 years ago

I have the need to filter which specific paths should be extracted from my Yaml files, not only on the key name.

To stay backwards compatible I didn't modify the handling of the keys parameter, but instead introduced a new one.

Example:

/usr/src/po4a/po4a-gettextize -d -f yaml -m en/antora-playbook.yml -o paths="site title,site url,asciidoc attributes idseparator" -o keys="url" -o skip_array

This would include all keys named url and additionally the specific elements addressed by the paths:

site:
  # matched by paths
  title: User Manual
  # matched by both
  url: https://manual.example.com/en
  start_page: index.adoc
content:
  sources:
  # matched by keys
   - url: ..
      branches: HEAD
      start_path: en/
ui:
  bundle:
    # matched by keys
    url: https://files.example.com/ui-bundle-release.zip
    snapshot: true
asciidoc:
  attributes:
    idprefix: ""
    # matched by paths
    idseparator: "-"
    kroki-fetch-diagram: true
    kroki-plantuml-include: style.puml
  extensions:
    - asciidoctor-kroki
mquinson commented 2 years ago

Hello there,

thanks for this pull request, that's really welcomed. But unfortunately, I cannot merge it until we have a sufficient set of tests covering this new feature. The CONTRIBUTING file shall explain how to add a new test, if I remember correctly.

Thanks again for your interest in po4a and for your contribution, Mt

oliverrahner commented 2 years ago

I added two tests, which cover the two new cases

mquinson commented 2 years ago

Merged, thanks.