plantuml-stdlib / C4-PlantUML

C4-PlantUML combines the benefits of PlantUML and the C4 model for providing a simple way of describing and communicate software architectures
MIT License
6.27k stars 1.09k forks source link

RELATIVE_INCLUDE variable breaking Antora builds #156

Closed scphantm closed 2 years ago

scphantm commented 3 years ago

This is basically a reopen of #118

I am having the identical error with an Antora build. I have tried every combination i can think of and everything fails. using the

!include C4_Context.puml

fails with the error

Skipping plantuml block. Preprocessing of PlantUML include failed, because reading the referenced local file '%get_variable_value("RELATIVE_INCLUDE")/C4.puml' caused an error:
Error: ENOENT: no such file or directory, open '%get_variable_value("RELATIVE_INCLUDE")/C4.puml'

switching to !include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Context.puml

gives me the same error.

Switching it to

!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/v2.0.1/C4.puml

finally worked, but obviously is a bad solution.

the problem is in this if statement

' convert it with additional command line argument -DRELATIVE_INCLUDE="." to use locally
!if %variable_exists("RELATIVE_INCLUDE")
  !include %get_variable_value("RELATIVE_INCLUDE")/C4.puml
!else
  !include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4.puml
!endif

in Antora, the concept of a file path is murky at best because antora loads the file system into kinda like an in memory graph (trying to be simple here, be gentle). the previous 2.0.1 version didn't have these if statements and work flawlessly.

Im running the latest and greatest of everything so let me know what i can do to help debug this. Maybe all it needs is something like this

' convert it with additional command line argument -DRELATIVE_INCLUDE="." to use locally
!if %variable_exists("RELATIVE_INCLUDE")
  !if %file_exists(%get_variable_value("RELATIVE_INCLUDE")/C4.puml)
     !include %get_variable_value("RELATIVE_INCLUDE")/C4.puml
  !else
     !include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4.puml
  !endif
!else
  !include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4.puml
!endif

if a file_exists is even possible. I don't know. just an idea.

kirchsth commented 3 years ago

I think it is solved with https://github.com/Mogztter/asciidoctor-kroki/issues/49 Can we close it?

kirchsth commented 3 years ago

Hi @scphantm PlantUml offers additional to !include an !include_many statement. The idea is that Antora does not support '!include_many' and therefore ignores it. Do you think that following implementation could help?

' convert it with additional command line argument -DRELATIVE_INCLUDE="." to use locally
!if %variable_exists("RELATIVE_INCLUDE")
  ' use !include_many that Kroki and Antora ignores the not supported calculated !include  
  !include_many %get_variable_value("RELATIVE_INCLUDE")/C4_Context.puml
!else
  !include https://raw.githubusercontent.com/kirchsth/C4-PlantUML/extended/C4_Context.puml
!endif

My extended branch is updated with !include_many. You can include it in your source like

!include https://raw.githubusercontent.com/kirchsth/C4-PlantUML/extended/C4_Context.puml

Can you try it? BR Helmut

kirchsth commented 3 years ago

@scphantm, @Potherca: I created a new plantuml-stdlib PR 42 that all new v.2.3.0 features can be used via stdlib too.

BR Helmut

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had activity in the past 60 days. It will be closed in seven days if no further activity occurs. Thank you for your contributions.