Skip to content
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

[Bug] Dokka Does Not Accept Using Directories for the Includes Property #3863

Open
solonovamax opened this issue Oct 16, 2024 · 1 comment · May be fixed by #3864
Open

[Bug] Dokka Does Not Accept Using Directories for the Includes Property #3863

solonovamax opened this issue Oct 16, 2024 · 1 comment · May be fixed by #3864
Assignees
Labels
bug runner: Gradle plugin An issue/PR related to Dokka's Gradle plugin

Comments

@solonovamax
Copy link

solonovamax commented Oct 16, 2024

Describe the Bug

When setting the "includes" for dokka, it will not accept directories.

Expected Behaviour

Directories are accepted when doing

dokka {
    dokkaSourceSets.configureEach {
        includes.from(file("dokka")) // here, dokka is a directory containing multiple markdown files
    }
}

Actual Behaviour

An error is produced when the above code is used.

Environment

  • Operating system: Linux
  • Build tool: Gradle 8.10.1
  • Dokka version: 2.0.0-Beta

Additional Information

The issue here is with the use of FileCollection.getFiles() on this line:

As-per the documentation:

Returns the contents of this collection as a Set. The contents of a file collection may change over time.
Note that this method returns File objects that represent locations on the file system. These File objects do not necessarily refer to regular files. Depending on the implementation of this file collection and how it has been configured, the returned set may contain directories, or missing files, or any other kind of file system element.

(emphasis my own)

Also, this same issue will apply to

  • classpath
  • samples
  • suppressedFiles

The solution to this would be to instead use a FileTree:

// files
classpath = spec.classpath.asFileTree.files.toList(),
includes = spec.includes.asFileTree.files,
samples = spec.samples.asFileTree.files,
sourceRoots = spec.sourceRoots.files,
suppressedFiles = spec.suppressedFiles.asFileTree.files,

however, I do believe it would be beneficial to expose suppressedFiles as a ConfigurableFileTree rather than a ConfigurableFileCollection. This is because it allows filtering:

dokka {
    dokkaSourceSets.configureEach {
        suppressedFiles.apply {
            from("src")
            include("**/internal/**")
            exclude("**/api/**")
        }
    }
}

however, this would be a breaking api change. Unsure if breaking api changes would be possible for the beta.
I am going to submit a PR that changes it to use a file tree, however.

solonovamax added a commit to solonovamax/dokka that referenced this issue Oct 16, 2024
tbh this test isn't exactly the *cleanest*, but whatever.

Signed-off-by: solonovamax <[email protected]>
solonovamax added a commit to solonovamax/dokka that referenced this issue Oct 16, 2024
Recursively resolve directories using `.asFileTree.files` instead of `.files`

Signed-off-by: solonovamax <[email protected]>
@adam-enko adam-enko self-assigned this Oct 16, 2024
@adam-enko adam-enko added the runner: Gradle plugin An issue/PR related to Dokka's Gradle plugin label Oct 16, 2024
@adam-enko
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug runner: Gradle plugin An issue/PR related to Dokka's Gradle plugin
Projects
None yet
2 participants