Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,11 @@ public static void start(ZnaiCliConfig cliConfig) {

public static void main(String[] args) {
ConsoleOutputs.add(new AnsiConsoleOutput());
start(new ZnaiCliConfig(System::exit, args));
ZnaiCliConfig cliConfig = new ZnaiCliConfig(System::exit, args);
if (cliConfig.isPrintOutsideDepsMode()) {
ConsoleOutputs.clear();
}
start(cliConfig);
}

private String getDocId() {
Expand Down Expand Up @@ -101,6 +105,8 @@ private void start() {
serve();
} else if (config.isExportMode()) {
export();
} else if (config.isPrintOutsideDepsMode()) {
printOutsideDeps();
} else if (config.isCustomCommand()) {
config.getSpecifiedCustomCommand().handle(
new CliCommandConfig(config.getDocId(), config.getSourceRoot(), config.getDeployRoot(), config.getActor()));
Expand Down Expand Up @@ -151,6 +157,15 @@ public void export() {
FileUtils.writeTextContent(lookupPath, artifactsDirName);
}

public void printOutsideDeps() {
Path sourceRoot = config.getSourceRoot();

webSite.getOutsideDocsRequestedResources().values().stream()
.map(fullPath -> sourceRoot.relativize(fullPath).toString())
.sorted()
.forEach(System.out::println);
}

private void exportLlmTxtIfNeeded() {
Path llmTxtOutputPath = config.getLlmTxtOutputPath();
if (llmTxtOutputPath == null) {
Expand Down Expand Up @@ -205,7 +220,7 @@ private WebSite generateDocs(Path sourceRoot) {
withValidateExternalLinks(config.isValidateExternalLinks()).
withLlmUrlPrefix(llmUrlPrefix == null ? "" : llmUrlPrefix);

return config.isExportMode() ?
return config.isExportMode() || config.isPrintOutsideDepsMode() ?
webSiteCfg.parseOnly():
webSiteCfg.deployTo(deployPath);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public enum Command {
SERVE("serve", "Serve static documentation"),
NEW("new", "Create new documentation with sample content and basic setup"),
EXPORT("export", "Export documentation source including required artifacts"),
PRINT_OUTSIDE_DEPS("print-outside-deps", "Print files outside docs root referenced by documentation"),
BUILD("build", "Build documentation (default)");

private final String name;
Expand Down Expand Up @@ -161,6 +162,8 @@ public boolean hasMultipleArgs() {
exportOptions.add(OptionKey.EXPORT);
COMMAND_OPTIONS.put(Command.EXPORT, exportOptions);

COMMAND_OPTIONS.put(Command.PRINT_OUTSIDE_DEPS, commonOptions);

COMMAND_OPTIONS.put(Command.NEW, commonOptions);
}

Expand Down Expand Up @@ -197,6 +200,7 @@ public enum Mode {
PREVIEW("preview"),
SERVE("serve"),
EXPORT("export"),
PRINT_OUTSIDE_DEPS("print-outside-deps"),
SCAFFOLD("scaffold new"),
CUSTOM("custom");

Expand Down Expand Up @@ -278,6 +282,10 @@ public boolean isExportMode() {
return mode == Mode.EXPORT;
}

public boolean isPrintOutsideDepsMode() {
return mode == Mode.PRINT_OUTSIDE_DEPS;
}

public boolean isCustomCommand() {
return !specifiedCustomCommands.isEmpty();
}
Expand Down Expand Up @@ -461,6 +469,7 @@ private Mode determineMode(CommandLine commandLine) {
case SERVE -> Mode.SERVE;
case NEW -> Mode.SCAFFOLD;
case EXPORT -> Mode.EXPORT;
case PRINT_OUTSIDE_DEPS -> Mode.PRINT_OUTSIDE_DEPS;
case BUILD -> Mode.BUILD;
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,8 @@ public static void add(ConsoleOutput consoleOutput) {
public static void remove(ConsoleOutput consoleOutput) {
outputs.remove(consoleOutput);
}

public static void clear() {
outputs.clear();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Add: `print-outside-deps` command to print file dependencies outside of documentation dir