ropensci-review-tools / babelquarto

Renders a Multilingual Quarto Project (Book or Website)
https://docs.ropensci.org/babelquarto/
Other
30 stars 6 forks source link

Can't use `-part` multiple times in _quarto.yml with multiple languages specified #32

Closed RealRichi3 closed 2 months ago

RealRichi3 commented 3 months ago

Description

I'm working on a project and wee use babelquarto to integrate the different languages into the rendered quarto website, but we ran into an issue earlier and haven't found away around it.

The issue is when i add multiple languages in the _quarto config and i use the part keyword multiple times babelquarto fails to render the book. It returns an error saying property name part is invalid

Here is a sample of my current _quarto.yml configuration

project:
  type: book
  output-dir: _book
website:
  title: JSQuarto Documentation
  description: Documentation for JSQuarto, a tool for generating JavaScript
    package API reference documentation using Markdown and Quarto.

book:
  title: Open Innovation Platform Documentation
  chapters:
  - index.md

  - part: Globals
    chapters:
      - chapters/globals/globals.qmd

  - part: Utilities
    chapters:
      - chapters/functional doc/utilities/constructidentifier.qmd
      - chapters/functional doc/utilities/commentsutil.qmd
      - chapters/functional doc/utilities/components.qmd
      - chapters/functional doc/utilities/file.qmd
      - chapters/functional doc/utilities/logger.qmd
      - chapters/functional doc/utilities/parser.qmd
      - chapters/functional doc/utilities/writer.qmd

  - part: Tutorials
    chapters:
      - chapters/tutorials/contributing/improving_documentation.qmd
      - chapters/tutorials/contributing/raising_issues.qmd
      - chapters/tutorials/contributing/raising_pr.qmd
      - chapters/tutorials/how_to/adding_tutorials.qmd
      - chapters/tutorials/how_to/optimizing_workflow.qmd
      - chapters/tutorials/how_to/starting_the_project.qmd
      - chapters/tutorials/project_structure.qmd
      - chapters/tutorials/environment_setup.qmd
      - chapters/tutorials/changelog.qmd
      - chapters/tutorials/localization.qmd

format:
  html:
    theme: cosmo
    highlight: github
    toc: true
    number-sections: false
babelquarto:
  languagecodes:
    - name: ar
      text: Version in ar
    - name: en
      text: Version in en
  mainlanguage: en
  languages:
    - ar
    - en
lang: en
title-ar: Title in ar
description-ar: Description in ar
author-ar: Author in ar
title-en: Title in en
description-en: Description in en
author-en: Author in en

Here is the error returned when i try to render the book

> babelquarto::render_book(project_path = project_dir)
[ 1/19] index.md
[ 2/19] chapters/globals/globals.qmd
[ 3/19] chapters/functional doc/utilities/constructidentifier.qmd
[ 4/19] chapters/functional doc/utilities/commentsutil.qmd
[ 5/19] chapters/functional doc/utilities/components.qmd
[ 6/19] chapters/functional doc/utilities/file.qmd
[ 7/19] chapters/functional doc/utilities/logger.qmd
[ 8/19] chapters/functional doc/utilities/parser.qmd
[ 9/19] chapters/functional doc/utilities/writer.qmd
[10/19] chapters/tutorials/contributing/improving_documentation.qmd
[11/19] chapters/tutorials/contributing/raising_issues.qmd
[12/19] chapters/tutorials/contributing/raising_pr.qmd
[13/19] chapters/tutorials/how_to/adding_tutorials.qmd
[14/19] chapters/tutorials/how_to/optimizing_workflow.qmd
[15/19] chapters/tutorials/how_to/starting_the_project.qmd
[16/19] chapters/tutorials/project_structure.qmd
[17/19] chapters/tutorials/environment_setup.qmd
[18/19] chapters/tutorials/changelog.qmd
[19/19] chapters/tutorials/localization.qmd

Output created: _book/index.html

ERROR: Project _quarto.yml validation failed.

In file _quarto.yml
(line 12, columns 5--9) property name part is invalid
11:   - index.md
12:   - part: Globals
       ~~~~~
13:     chapters: chapters/globals/globals.ar.qmd
ℹ The error happened in location book:chapters:1:part.

In file _quarto.yml
(line 13, columns 5--13) property name chapters is invalid
12:   - part: Globals
13:     chapters: chapters/globals/globals.ar.qmd
       ~~~~~~~~~
14:   - part: Utilities
ℹ The error happened in location book:chapters:1:chapters.

Stack trace:

In file _quarto.yml
(line 12, columns 5--9) property name part is invalid
11:   - index.md
12:   - part: Globals
       ~~~~~
13:     chapters: chapters/globals/globals.ar.qmd
ℹ The error happened in location book:chapters:1:part.

In file _quarto.yml
(line 13, columns 5--13) property name chapters is invalid
12:   - part: Globals
13:     chapters: chapters/globals/globals.ar.qmd
       ~~~~~~~~~
14:   - part: Utilities
ℹ The error happened in location book:chapters:1:chapters.

    at readAndValidateYamlFromFile (file:///opt/quarto/bin/quarto.js:20470:15)
    at async file:///opt/quarto/bin/quarto.js:72903:26
    at async projectContext (file:///opt/quarto/bin/quarto.js:72737:26)
    at async render (file:///opt/quarto/bin/quarto.js:81779:19)
    at async Command.fn (file:///opt/quarto/bin/quarto.js:81954:32)
    at async Command.execute (file:///opt/quarto/bin/quarto.js:8104:13)
    at async quarto (file:///opt/quarto/bin/quarto.js:114968:5)
    at async file:///opt/quarto/bin/quarto.js:114986:9
Error in `quarto::quarto_render()`:
✖ Error running quarto cli.
Caused by error:

See

Please see the parent issue Open-Science-Community-Saudi-Arabia/JSquarto#35 for more info on how to replicate it

maelle commented 3 months ago

:wave: @RealRichi3!

In the rOpenSci dev guide, built with babelquarto, we use parts: https://github.com/ropensci/dev_guide/blob/main/_quarto.yml so I suspect your problem might be a YAML formatting issue. (not saying there can't be a bug here, this is also possible :sweat_smile:)

Could you try removing the space before the hyphens in chapter lists? Like so:

project:
  type: book
  output-dir: _book
website:
  title: JSQuarto Documentation
  description: Documentation for JSQuarto, a tool for generating JavaScript
    package API reference documentation using Markdown and Quarto.

book:
  title: Open Innovation Platform Documentation
  chapters:
  - index.md

  - part: Globals
    chapters:
    - chapters/globals/globals.qmd

  - part: Utilities
    chapters:
    - chapters/functional doc/utilities/constructidentifier.qmd
    - chapters/functional doc/utilities/commentsutil.qmd
    - chapters/functional doc/utilities/components.qmd
    - chapters/functional doc/utilities/file.qmd
    - chapters/functional doc/utilities/logger.qmd
    - chapters/functional doc/utilities/parser.qmd
    - chapters/functional doc/utilities/writer.qmd

  - part: Tutorials
    chapters:
    - chapters/tutorials/contributing/improving_documentation.qmd
    - chapters/tutorials/contributing/raising_issues.qmd
    - chapters/tutorials/contributing/raising_pr.qmd
    - chapters/tutorials/how_to/adding_tutorials.qmd
    - chapters/tutorials/how_to/optimizing_workflow.qmd
    - chapters/tutorials/how_to/starting_the_project.qmd
    - chapters/tutorials/project_structure.qmd
    - chapters/tutorials/environment_setup.qmd
    - chapters/tutorials/changelog.qmd
    - chapters/tutorials/localization.qmd

format:
  html:
    theme: cosmo
    highlight: github
    toc: true
    number-sections: false
babelquarto:
  languagecodes:
    - name: ar
      text: Version in ar
    - name: en
      text: Version in en
  mainlanguage: en
  languages:
    - ar
    - en
lang: en
title-ar: Title in ar
description-ar: Description in ar
author-ar: Author in ar
title-en: Title in en
description-en: Description in en
author-en: Author in en

I don't have time to try it out just now but if it doesn't work, please ping me again!

RealRichi3 commented 3 months ago

Thanks @maelle, i'll try it out and get back to you

RealRichi3 commented 3 months ago

I just tried it, but it returned the same error


Output created: _book/index.html

ERROR: Project _quarto.yml validation failed.

In file _quarto.yml
(line 12, columns 5--9) property name part is invalid
11:   - index.md
12:   - part: Globals
       ~~~~~
13:     chapters: chapters/globals/globals.ar.qmd
ℹ The error happened in location book:chapters:1:part.

In file _quarto.yml
(line 13, columns 5--13) property name chapters is invalid
12:   - part: Globals
13:     chapters: chapters/globals/globals.ar.qmd
       ~~~~~~~~~
14:   - part: Utilities
ℹ The error happened in location book:chapters:1:chapters.

Stack trace:

In file _quarto.yml
(line 12, columns 5--9) property name part is invalid
11:   - index.md
12:   - part: Globals
       ~~~~~
13:     chapters: chapters/globals/globals.ar.qmd
ℹ The error happened in location book:chapters:1:part.

In file _quarto.yml
(line 13, columns 5--13) property name chapters is invalid
12:   - part: Globals
13:     chapters: chapters/globals/globals.ar.qmd
       ~~~~~~~~~
14:   - part: Utilities
ℹ The error happened in location book:chapters:1:chapters.

    at readAndValidateYamlFromFile (file:///opt/quarto/bin/quarto.js:20470:15)
    at async file:///opt/quarto/bin/quarto.js:72903:26
    at async projectContext (file:///opt/quarto/bin/quarto.js:72737:26)
    at async render (file:///opt/quarto/bin/quarto.js:81779:19)
    at async Command.fn (file:///opt/quarto/bin/quarto.js:81954:32)
    at async Command.execute (file:///opt/quarto/bin/quarto.js:8104:13)
    at async quarto (file:///opt/quarto/bin/quarto.js:114968:5)
    at async file:///opt/quarto/bin/quarto.js:114986:9
maelle commented 3 months ago

I'll try it out tomorrow or next week then!

RealRichi3 commented 3 months ago

Alright, thanks

maelle commented 2 months ago

Some progress in #33. I can build the book but not all links are created. I'll explore further.

I'd recommend not using space in folder names.

maelle commented 2 months ago

@RealRichi3 I'll soon merge my PR. However for the links to work for the homepage of the different versions you'll have to rename index.md to index.qmd (and to update the _quarto.yml file accordingly).

RealRichi3 commented 2 months ago

Thanks @maelle, i'll try it again and give you feedbck

RealRichi3 commented 2 months ago

It works fine now, thanks @maelle

maelle commented 2 months ago

Awesome, glad to hear :tada: Thank you for catching not one but :sparkles: two :sparkles: bugs, that was an efficient bug report. :wink: