Skip to content

Commit

Permalink
support recursive resource copying (closes #44)
Browse files Browse the repository at this point in the history
  • Loading branch information
Simn committed Oct 13, 2014
1 parent 2cd1f38 commit 10a72ae
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 7 deletions.
11 changes: 10 additions & 1 deletion src/dox/Processor.hx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package dox;

import haxe.rtti.CType;
using Lambda;
using StringTools;

class Processor {

Expand Down Expand Up @@ -161,6 +162,11 @@ class Processor {
return newRoot;
}

function makeFilePathRelative(t:TypeInfos) {
var path = t.module == null ? t.path : t.module;
t.file = path.replace(".", "/") + ".hx";
}

function processTree(tree:TypeTree)
{
switch (tree)
Expand All @@ -173,7 +179,7 @@ class Processor {
config.setRootPath(t.path);
t.doc = processDoc(t.path, t.doc);
t.constructors.iter(processEnumField.bind(t.path));

makeFilePathRelative(t);
case TTypedecl(t):
config.setRootPath(t.path);
t.doc = processDoc(t.path, t.doc);
Expand All @@ -182,6 +188,7 @@ class Processor {
case CAnonymous(fields): fields.iter(processClassField.bind(t.path));
default:
}
makeFilePathRelative(t);
case TClassdecl(t):
config.setRootPath(t.path);
t.doc = processDoc(t.path, t.doc);
Expand All @@ -195,6 +202,7 @@ class Processor {
if (!infos.implementors.exists(i.path)) infos.implementors.set(i.path, [t]);
else infos.implementors.get(i.path).push(t);
}
makeFilePathRelative(t);
case TAbstractdecl(t):
config.setRootPath(t.path);
if (t.impl != null)
Expand All @@ -203,6 +211,7 @@ class Processor {
t.impl.statics.iter(processClassField.bind(t.path));
}
t.doc = processDoc(t.path, t.doc);
makeFilePathRelative(t);
}
}

Expand Down
23 changes: 17 additions & 6 deletions src/dox/Writer.hx
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,25 @@ class Writer {
}

public function copyFrom(dir:String) {
for (file in sys.FileSystem.readDirectory(dir)) {
var path = '$dir/$file';
if (zipEntries != null) {
makeEntry(file, sys.io.File.getBytes(path));
} else {
sys.io.File.copy(path, haxe.io.Path.join([config.outputPath, file]));
function loop(rel) {
var dir = haxe.io.Path.join([dir, rel]);
for (file in sys.FileSystem.readDirectory(dir)) {
var path = haxe.io.Path.join([dir, file]);
if (sys.FileSystem.isDirectory(path)) {
var outDir = haxe.io.Path.join([config.outputPath, rel, file]);
if (!sys.FileSystem.exists(outDir))
sys.FileSystem.createDirectory(outDir);
loop(haxe.io.Path.join([rel, file]));
} else {
if (zipEntries != null) {
makeEntry(haxe.io.Path.join([rel, file]), sys.io.File.getBytes(path));
} else {
sys.io.File.copy(path, haxe.io.Path.join([config.outputPath, rel, file]));
}
}
}
}
loop("");
}

public function finalize() {
Expand Down

1 comment on commit 10a72ae

@Gama11
Copy link
Member

@Gama11 Gama11 commented on 10a72ae Jun 18, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makeFilePathRelative() poses a bit of an issue for #224 (suddenly everything has a .hx source file)... Why is that done in the first place? Doesn't seem like Writer uses TypeInfos.file.

Please sign in to comment.