Skip to content

Commit 081a0e8

Browse files
authored
Allow to set an alternative source directory (for editing) (#625)
Always check if a file is existing before returning true for isEditable and non-null for getDoxiaSourcePath()/getDoxiaSourcePath(String) This closes #277
1 parent e3aded9 commit 081a0e8

File tree

6 files changed

+352
-124
lines changed

6 files changed

+352
-124
lines changed

doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/DefaultSiteRenderer.java

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -198,12 +198,11 @@ public Map<String, DocumentRenderer> locateDocumentFiles(SiteRenderingContext si
198198

199199
addModuleFiles(
200200
siteRenderingContext.getRootDirectory(),
201+
siteDirectory,
201202
moduleBasedir,
202203
module,
203204
excludes,
204-
files,
205-
siteDirectory.isEditable(),
206-
siteDirectory.isSkipDuplicates());
205+
files);
207206
}
208207
}
209208
}
@@ -228,32 +227,27 @@ private List<String> filterExtensionIgnoreCase(List<String> fileNames, String ex
228227
* Populates the files map with {@link DocumentRenderer}s per output name in parameter {@code files} for all files in the moduleBasedir matching the module extensions,
229228
* taking care of duplicates if needed.
230229
*
231-
* @param rootDir
230+
* @param siteRootDirectory
231+
* @param siteDirectory
232232
* @param moduleBasedir
233233
* @param module
234234
* @param excludes
235235
* @param files
236-
* @param editable
237-
* @param skipDuplicates
238236
* @throws IOException
239237
* @throws RendererException
240238
*/
241239
private void addModuleFiles(
242-
File rootDir,
240+
File siteRootDirectory,
241+
SiteDirectory siteDirectory,
243242
File moduleBasedir,
244243
ParserModule module,
245244
String excludes,
246-
Map<String, DocumentRenderer> files,
247-
boolean editable,
248-
boolean skipDuplicates)
245+
Map<String, DocumentRenderer> files)
249246
throws IOException, RendererException {
250247
if (!moduleBasedir.exists() || ArrayUtils.isEmpty(module.getExtensions())) {
251248
return;
252249
}
253250

254-
String moduleRelativePath =
255-
PathTool.getRelativeFilePath(rootDir.getAbsolutePath(), moduleBasedir.getAbsolutePath());
256-
257251
List<String> allFiles = FileUtils.getFileNames(moduleBasedir, "**/*", excludes, false);
258252

259253
for (String extension : module.getExtensions()) {
@@ -268,14 +262,20 @@ private void addModuleFiles(
268262

269263
for (String doc : docs) {
270264
DocumentRenderingContext docRenderingContext = new DocumentRenderingContext(
271-
moduleBasedir, moduleRelativePath, doc, module.getParserId(), extension, editable);
265+
moduleBasedir,
266+
doc,
267+
module.getParserId(),
268+
extension,
269+
siteRootDirectory,
270+
siteDirectory.getPath(),
271+
siteDirectory.getEditableSourceDirectories());
272272

273273
// TODO: DOXIA-111: we need a general filter here that knows how to alter the context
274274
if (endsWithIgnoreCase(doc, ".vm")) {
275275
docRenderingContext.setAttribute("velocity", "true");
276276
}
277277

278-
if (!checkForDuplicate(docRenderingContext, files, skipDuplicates)) {
278+
if (!checkForDuplicate(docRenderingContext, files, siteDirectory.isSkipDuplicates())) {
279279
String key = docRenderingContext.getOutputName();
280280
files.put(key, new DoxiaDocumentRenderer(docRenderingContext));
281281
}

0 commit comments

Comments
 (0)