Added support for an alternative current dir mode in pkldoc (#824)

Some systems have trouble with handling symlinks, which breaks the current directory links created by Pkldoc. In this PR, we add an alternative mode which creates a full copy of the latest published version contents in the current directory instead.

Co-authored-by: Dan Chao <dan.chao@apple.com>
This commit is contained in:
Vladimir Matveev
2025-02-19 08:52:32 -08:00
committed by GitHub
parent 2ffd201172
commit baa34a6dd1
11 changed files with 143 additions and 19 deletions

View File

@@ -261,8 +261,14 @@ public class PklPlugin implements Plugin<Project> {
.getBuildDirectory()
.map(it -> it.dir("pkldoc").dir(spec.getName())));
spec.getNoSymlinks().convention(false);
createModulesTask(PkldocTask.class, spec)
.configure(task -> task.getOutputDir().set(spec.getOutputDir()));
.configure(
task -> {
task.getOutputDir().set(spec.getOutputDir());
task.getNoSymlinks().set(spec.getNoSymlinks());
});
});
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,8 +16,11 @@
package org.pkl.gradle.spec;
import org.gradle.api.file.DirectoryProperty;
import org.gradle.api.provider.Property;
/** Configuration options for Pkldoc generators. Documented in user manual. */
public interface PkldocSpec extends ModulesSpec {
DirectoryProperty getOutputDir();
Property<Boolean> getNoSymlinks();
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,6 +16,8 @@
package org.pkl.gradle.task;
import org.gradle.api.file.DirectoryProperty;
import org.gradle.api.provider.Property;
import org.gradle.api.tasks.Input;
import org.gradle.api.tasks.OutputDirectory;
import org.pkl.doc.CliDocGenerator;
import org.pkl.doc.CliDocGeneratorOptions;
@@ -24,11 +26,17 @@ public abstract class PkldocTask extends ModulesTask {
@OutputDirectory
public abstract DirectoryProperty getOutputDir();
@Input
public abstract Property<Boolean> getNoSymlinks();
@Override
protected void doRunTask() {
new CliDocGenerator(
new CliDocGeneratorOptions(
getCliBaseOptions(), getOutputDir().get().getAsFile().toPath()))
getCliBaseOptions(),
getOutputDir().get().getAsFile().toPath(),
false,
getNoSymlinks().get()))
.run();
}
}