-
Notifications
You must be signed in to change notification settings - Fork 119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Resolving files relative to sourceDir (Issue in 1.5.1-SNAPSHOT) #122
Comments
I think this section of code in private void validateSourceDocuments(FileCollection srcDocs) {
srcDocs.files.findAll {
it.isAbsolute() && !it.canonicalPath.startsWith(sourceDir.canonicalPath)
}.each {
logger.warn("Entry '$it' of `sourceDocumentNames` should be specified relative to `sourceDir` ($sourceDir)")
}
Collection<File> allReachableFiles = []
eachFileRecurse(sourceDir, EXCLUDE_DOCINFO_AND_FILES_STARTING_WITH_UNDERSCORE) { File file ->
allReachableFiles.add(file)
}
srcDocs.files.each { File file ->
if (! allReachableFiles.find {it.canonicalPath == file.canonicalPath}) {
throw new GradleException("'$file' is not reachable from sourceDir ($sourceDir). " +
'All files given in `sourceDocumentNames` must be located in `sourceDir` ' +
'or a subfolder of `sourceDir`.')
}
}
} Based upon this, I think there is an issue in asciidoctor {
sourceDir 'src/asciidoc'
sourceDocumentNames 'slides.adoc'
} It resolves to |
The slides.adoc example you gave should definitely resolve to I do think that cases 1-4 are all reasonable to support. 5 should be frowned upon because it makes for a non-portable build (referencing an external file). However, we don't have to support all the cases 1 - 4. We should support the cases that are necessary based on user requirements / feedback. |
I want to address the question about why the sourceDocumentNames are relative to the sourceDir, and why we have sourceDir. The reason we have sourceDir is to put AsciidoctorJ (and thus Asciidoctor) into the context of the documentation folder, similar to if we were using the The challenge we currently face with regard to this relative root is that Asciidoctor is currently trying to represent two concepts with only a single option. I'll explain. Currently, the only way to define the "root" directory in Asciidoctor is by setting the In Asciidoctor core, we need to split base_dir into two options: base_dir and jail_dir (or chroot). That allows us to define the confined space in which Asciidoctor should work, but also to set a root directory for resolving things like includes. Then, this becomes a much simpler problem in build environments like Gradle. See asciidoctor/asciidoctor#682 As a general word of advice, you want to avoid setting a root (i.e., base_dir) as the project dir because then it breaks the AsciiDoc file preview when viewed in any other context (such as in the Chrome extension). We don't want to couple the AsciiDoc files to the Gradle build in that way...so it's important to use the most universal idea of a base directory and then work from there. This is also one of the main reasons we advocate for always prefixing the include target with a variable, such as {projectdir}, etc. Then, you can control the resolution of the targets in a much more fine-grained way. |
I'm with @mojavelinux here, the |
I have a fix for that; will create a PR. |
If I understand this correctly, the true aim is not to restrict people in the way they build docuemtns with Asciidoctor. Someone who also uses the chrome extension would want to have everything below Consider an alternative use-case using my gist on including deck.js without git submodules as example. In this case So I would guess that what needs to be descendents of This really brings me to another thing - images (videos etc.). I suspect convention is just to have that as a subfolder of File target = new File(destinationParentDir, file.name)
target.withOutputStream { it << file.newInputStream() } in |
Not necessarily. Image paths are determines by the |
This is more of a question and it is about structuring files and it has been confusing me the last couple of days. We'll need to update the README with the correct details so here goes
Given a file structure
and
Which of the following 5 are valid?
From my understanding
Would like to hear what @aalmiray has to say on this one.
The text was updated successfully, but these errors were encountered: