|
10 | 10 | //
|
11 | 11 |
|
12 | 12 | #include "AdocWriter.hpp"
|
| 13 | +#include "ConfigImpl.hpp" |
13 | 14 | #include "Support/Validate.hpp"
|
14 | 15 | #include <mrdox/Metadata.hpp>
|
15 | 16 | #include <mrdox/Metadata/Overloads.hpp>
|
16 | 17 | #include <clang/Basic/Specifiers.h>
|
| 18 | +#include <llvm/Support/YAMLParser.h> |
| 19 | +#include <llvm/Support/YAMLTraits.h> |
| 20 | + |
| 21 | +//------------------------------------------------ |
| 22 | +// |
| 23 | +// YAML |
| 24 | +// |
| 25 | +//------------------------------------------------ |
| 26 | + |
| 27 | +namespace clang { |
| 28 | +namespace mrdox { |
| 29 | +namespace adoc { |
| 30 | + |
| 31 | +struct AdocWriter::Key |
| 32 | +{ |
| 33 | + Options& opt; |
| 34 | + |
| 35 | + explicit |
| 36 | + Key( |
| 37 | + Options& opt_) noexcept |
| 38 | + : opt(opt_) |
| 39 | + { |
| 40 | + } |
| 41 | +}; |
| 42 | + |
| 43 | +struct AdocWriter::GenKey |
| 44 | +{ |
| 45 | + Options& opt; |
| 46 | + |
| 47 | + explicit |
| 48 | + GenKey( |
| 49 | + Options& opt_) |
| 50 | + : opt(opt_) |
| 51 | + { |
| 52 | + } |
| 53 | +}; |
| 54 | + |
| 55 | +} // adoc |
| 56 | +} // mrdox |
| 57 | +} // clang |
| 58 | + |
| 59 | +template<> |
| 60 | +struct llvm::yaml::MappingTraits< |
| 61 | + clang::mrdox::adoc::AdocWriter::Key> |
| 62 | +{ |
| 63 | + static void mapping(IO& io, |
| 64 | + clang::mrdox::adoc::AdocWriter::Key& opt_) |
| 65 | + { |
| 66 | + auto& opt= opt_.opt; |
| 67 | + io.mapOptional("safe-names", opt.safe_names); |
| 68 | + } |
| 69 | +}; |
| 70 | + |
| 71 | +template<> |
| 72 | +struct llvm::yaml::MappingTraits< |
| 73 | + clang::mrdox::adoc::AdocWriter::GenKey> |
| 74 | +{ |
| 75 | + static void mapping(IO& io, |
| 76 | + clang::mrdox::adoc::AdocWriter::GenKey& opt) |
| 77 | + { |
| 78 | + clang::mrdox::adoc::AdocWriter::Key k(opt.opt); |
| 79 | + |
| 80 | + io.mapOptional("adoc", k); |
| 81 | + } |
| 82 | +}; |
| 83 | + |
| 84 | +template<> |
| 85 | +struct llvm::yaml::MappingTraits< |
| 86 | + clang::mrdox::adoc::AdocWriter::Options> |
| 87 | +{ |
| 88 | + static void mapping(IO& io, |
| 89 | + clang::mrdox::adoc::AdocWriter::Options& opt) |
| 90 | + { |
| 91 | + clang::mrdox::adoc::AdocWriter::GenKey k(opt); |
| 92 | + io.mapOptional("generator", k); |
| 93 | + } |
| 94 | +}; |
17 | 95 |
|
18 | 96 | namespace clang {
|
19 | 97 | namespace mrdox {
|
@@ -97,6 +175,32 @@ AdocWriter(
|
97 | 175 | {
|
98 | 176 | }
|
99 | 177 |
|
| 178 | +llvm::Error |
| 179 | +AdocWriter:: |
| 180 | +init() |
| 181 | +{ |
| 182 | + { |
| 183 | + llvm::yaml::Input yin( |
| 184 | + corpus_.config()->configYaml().first, |
| 185 | + this, ConfigImpl::yamlDiagnostic); |
| 186 | + yin.setAllowUnknownKeys(true); |
| 187 | + yin >> options_; |
| 188 | + if(auto ec = yin.error()) |
| 189 | + return makeError(ec); |
| 190 | + } |
| 191 | + { |
| 192 | + llvm::yaml::Input yin( |
| 193 | + corpus_.config()->configYaml().second, |
| 194 | + this, ConfigImpl::yamlDiagnostic); |
| 195 | + yin.setAllowUnknownKeys(true); |
| 196 | + yin >> options_; |
| 197 | + if(auto ec = yin.error()) |
| 198 | + return makeError(ec); |
| 199 | + } |
| 200 | + |
| 201 | + return llvm::Error::success(); |
| 202 | +} |
| 203 | + |
100 | 204 | //------------------------------------------------
|
101 | 205 |
|
102 | 206 | /* Write a namespace.
|
|
0 commit comments