mirror of https://github.com/exaloop/codon.git
Update docgen signature
parent
33a82967d8
commit
f09ac6d85f
|
@ -65,9 +65,9 @@ int docMode(const std::vector<const char *> &args, const std::string &argv0) {
|
|||
files.push_back(line);
|
||||
|
||||
auto compiler = std::make_unique<codon::Compiler>(args[0]);
|
||||
std::string result;
|
||||
bool failed = false;
|
||||
llvm::handleAllErrors(compiler->docgen(files, &result),
|
||||
auto result = compiler->docgen(files);
|
||||
llvm::handleAllErrors(result.takeError(),
|
||||
[&failed](const codon::error::ParserErrorInfo &e) {
|
||||
display(e);
|
||||
failed = true;
|
||||
|
@ -75,7 +75,7 @@ int docMode(const std::vector<const char *> &args, const std::string &argv0) {
|
|||
if (failed)
|
||||
return EXIT_FAILURE;
|
||||
|
||||
fmt::print("{}\n", result);
|
||||
fmt::print("{}\n", *result);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
|
@ -100,16 +100,13 @@ void Compiler::compile() {
|
|||
llvisitor->visit(module.get());
|
||||
}
|
||||
|
||||
llvm::Error Compiler::docgen(const std::vector<std::string> &files,
|
||||
std::string *output) {
|
||||
llvm::Expected<std::string> Compiler::docgen(const std::vector<std::string> &files) {
|
||||
try {
|
||||
auto j = ast::DocVisitor::apply(argv0, files);
|
||||
if (output)
|
||||
*output = j->toString();
|
||||
return j->toString();
|
||||
} catch (exc::ParserException &e) {
|
||||
return llvm::make_error<error::ParserErrorInfo>(e);
|
||||
}
|
||||
return llvm::Error::success();
|
||||
}
|
||||
|
||||
} // namespace codon
|
||||
|
|
|
@ -49,7 +49,7 @@ public:
|
|||
int testFlags = 0,
|
||||
const std::unordered_map<std::string, std::string> &defines = {});
|
||||
void compile();
|
||||
llvm::Error docgen(const std::vector<std::string> &files, std::string *output);
|
||||
llvm::Expected<std::string> docgen(const std::vector<std::string> &files);
|
||||
};
|
||||
|
||||
} // namespace codon
|
||||
|
|
Loading…
Reference in New Issue