Lines Matching +full:- +full:no +full:- +full:sphinx
1 //===-- ClangOptionDocEmitter.cpp - Documentation for command line flags --===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
9 //===----------------------------------------------------------------------===//
44 for (const Record *Flag : Option->getValueAsListOfDefs(FlagsField))
45 if (Flag->getName() == OptionFlag)
47 if (const DefInit *DI = dyn_cast<DefInit>(Option->getValueInit("Group")))
48 for (const Record *Flag : DI->getDef()->getValueAsListOfDefs(FlagsField))
49 if (Flag->getName() == OptionFlag)
55 for (StringRef IgnoredFlag : DocInfo->getValueAsListOfStrings("IgnoreFlags"))
58 for (StringRef Mask : DocInfo->getValueAsListOfStrings("VisibilityMask"))
70 // (Record*)nullptr, which contains all top-level groups and options.
77 OptionsByName[std::string(R->getValueAsString("Name"))] = R;
80 return R->getValue("DocFlatten") && R->getValueAsBit("DocFlatten");
83 auto SkipFlattened = [&](const Record *R) -> const Record * {
85 auto *G = dyn_cast<DefInit>(R->getValueInit("Group"));
88 R = G->getDef();
98 if (auto *G = dyn_cast<DefInit>(R->getValueInit("Group")))
99 Group = SkipFlattened(G->getDef());
104 if (auto *A = dyn_cast<DefInit>(R->getValueInit("Alias"))) {
105 Aliases[A->getDef()].push_back(R);
109 // Pretend no-X and Xno-Y options are aliases of X and XY.
110 std::string Name = std::string(R->getValueAsString("Name"));
112 if (Name.substr(0, 3) == "no-" && OptionsByName[Name.substr(3)]) {
116 if (Name.substr(1, 3) == "no-" && OptionsByName[Name[0] + Name.substr(4)]) {
123 if (auto *G = dyn_cast<DefInit>(R->getValueInit("Group")))
124 Group = SkipFlattened(G->getDef());
129 return A->getValueAsString("Name") < B->getValueAsString("Name");
133 return A->getLoc()[0].getPointer() < B->getLoc()[0].getPointer();
136 auto DocumentationForOption = [&](const Record *R) -> DocumentedOption {
143 [&](const Record *R) -> Documentation {
171 return StringSwitch<std::pair<StringRef, StringRef>>(OptionKind->getName())
179 const unsigned UnlimitedArgs = unsigned(-1);
181 // Get the number of arguments expected for an option, or -1 if any number of
184 return StringSwitch<unsigned>(OptionKind->getName())
189 .Case("KIND_MULTIARG", Option->getValueAsInt("NumArgs"))
205 if (!isalnum(*I) && *I != '-')
206 return OptionName.substr(0, I - OptionName.begin());
211 // HACK: Work arond sphinx's inability to cope with punctuation-only options
213 for (char C : Option->getValueAsString("Name"))
222 << std::string(Heading.size(), "=~-_'+<>"[Depth]) << "\n";
230 if (auto *V = R->getValue(Field)) {
232 if (auto *SV = dyn_cast_or_null<StringInit>(V->getValue()))
233 Value = SV->getValue();
243 OS << Prefix << escapeRST(Option->getValueAsString("Name"));
246 getSeparatorsForKind(Option->getValueAsDef("Kind"));
259 unsigned NumArgs = getNumArgsForKind(Option->getValueAsDef("Kind"), Option);
260 bool HasMetaVarName = !Option->isValueUnset("MetaVarName");
264 Args.push_back(std::string(Option->getValueAsString("MetaVarName")));
276 // Use '--args <arg1> <arg2>...' if any number of args are allowed.
287 auto AliasArgs = Option->getValueAsListOfStrings("AliasArgs");
289 const Record *Alias = Option->getValueAsDef("Alias");
292 Alias->getValueAsListOfStrings("Prefixes").front(), Alias,
299 for (auto &Prefix : Option->getValueAsListOfStrings("Prefixes")) {
321 if (Option.Option->getValueAsDef("Kind")->getName() == "KIND_UNKNOWN" ||
322 Option.Option->getValueAsDef("Kind")->getName() == "KIND_INPUT")
328 // sphinx's inability to cope with options that differ only by punctuation
329 // (eg -ObjC vs -ObjC++, -G vs -G=).
332 for (auto &Prefix : Option->getValueAsListOfStrings("Prefixes"))
334 (Prefix + Option->getValueAsString("Name")).str())));
336 assert(!SphinxOptionIDs.empty() && "no flags for option");
346 std::string Program = DocInfo->getValueAsString("Program").lower();
367 R->getValueAsListOfDefs("HelpTextsForVariants")) {
370 VisibilityHelp->getValueAsListInit("Visibilities")->getValues();
374 DocInfo->getValueAsListOfStrings("VisibilityMask")) {
376 if (Visibility->getAsUnquotedString() == DocInfoMask) {
378 Description = escapeRST(VisibilityHelp->getValueAsString("Text"));
394 if (!isa<UnsetInit>(R->getValueInit("Values"))) {
399 if (!isa<UnsetInit>(R->getValueInit("MetaVarName")))
400 MetaVarName = R->getValueAsString("MetaVarName");
405 SplitString(R->getValueAsString("Values"), Values, ",");
408 Description += join(Values.begin(), Values.end() - 1, "', '");
449 PrintFatalError("The GlobalDocumentation top-level definition is missing, "
450 "no documentation will be generated.");
453 OS << DocInfo->getValueAsString("Intro") << "\n";
454 OS << ".. program:: " << DocInfo->getValueAsString("Program").lower() << "\n";