When running PlantUML from a python program , the !include directive cannot find files. (The python program is sphinx-contrib/plantuml (https://github.com/sphinx-contrib/plantuml)
I've seen the question "Latest PlantUML (Version 1.2018.11) cannot !include with pipe" and downloaded the beta .jar. But am still having the same problem:
Preprocessor Error: Cannot include plantuml-includes/simple-plantuml-styles.iuml
It fails if the !include is within the .puml file, and it fails if the -I option is used in the command line
I put in some print statements to do some debugging and what I notice is that in net.sourceforge.plantuml.preproc2.PreprocessorInclude3.manageFileInclude, after this line:
final FileWithSuffix f2 = new FileWithSuffix(importedFiles, withEnvironmentVariable(fileName), suf);
idx == -1 and
f2.file is null.
Here's what the print statement reveals when I run it from the python program (I added a toString() method for FileWithSuffix so I could display info about it.):
PLANTUML: in PreprocessorInclude3.manageFileInclude: FileWithSuffix f2 = net.sourceforge.plantuml.preproc.FileWithSuffix suffix: null description: plantuml-includes/simple-plantuml-styles.iuml entry: (null) file: NULL!
Preprocessor Error: Cannot include plantuml-includes/simple-plantuml-styles.iuml
Just in case it's helpful, the python code used to run PlantUML is:
subprocess.Popen( plantuml_cmd,
stdout=f,
stdin=subprocess.PIPE,
stderr=subprocess.PIPE,
cwd=absincdir )
where:
plantuml_cmd is the command line used:
java -jar plantuml.jar -Djava.awt.headless=true -pipe -charset UTF-8' -filename seq-with-include.puml
f is a File
absincdir is the directory where the .puml file is. In this case the file to be included is in the subdirectory in this directory, too. IOW:
/ <absincdir>
seq-with-include.puml
/plantuml-includes
simple-plantuml-styles.ipuml
And the file seq-with-includes.puml has this line in it:
!include plantuml-includes/simple-plantuml-styles.ipuml