bool AbstractCompositeHelpTopic::writeSubTopicList(const HelpWriterContext &context, const std::string &title) const { if (context.outputFormat() != eHelpOutputFormat_Console) { Impl::SubTopicList::const_iterator topic; for (topic = impl_->subTopics_.begin(); topic != impl_->subTopics_.end(); ++topic) { const char *const title = (*topic)->title(); if (!isNullOrEmpty(title)) { context.outputFile().writeLine(); HelpWriterContext subContext(context); subContext.enterSubSection(title); (*topic)->writeHelp(subContext); } } return true; } int maxNameLength = 0; Impl::SubTopicMap::const_iterator topic; for (topic = impl_->subTopicMap_.begin(); topic != impl_->subTopicMap_.end(); ++topic) { const char *const title = topic->second->title(); if (!isNullOrEmpty(title)) { int nameLength = static_cast<int>(topic->first.length()); if (nameLength > maxNameLength) { maxNameLength = nameLength; } } } if (maxNameLength == 0) { return false; } TextWriter &file = context.outputFile(); TextTableFormatter formatter; formatter.addColumn(NULL, maxNameLength + 1, false); formatter.addColumn(NULL, 72 - maxNameLength, true); formatter.setFirstColumnIndent(4); file.writeLine(title); for (topic = impl_->subTopicMap_.begin(); topic != impl_->subTopicMap_.end(); ++topic) { const char *const name = topic->first.c_str(); const char *const title = topic->second->title(); if (!isNullOrEmpty(title)) { formatter.clear(); formatter.addColumnLine(0, name); formatter.addColumnLine(1, title); file.writeString(formatter.formatRow()); } } return true; }
void CommandLineHelpWriter::Impl::formatBugs(const HelpWriterContext &context) { if (bugs_.empty()) { return; } context.writeTitle("Known Issues"); ConstArrayRef<const char *>::const_iterator i; for (i = bugs_.begin(); i != bugs_.end(); ++i) { const char *const bug = *i; context.writeTextBlock(formatString("* %s", bug)); } }
void CommandLineHelpWriter::Impl::formatBugs(const HelpWriterContext &context) { if (bugs_.empty()) { return; } context.writeTitle("Known Issues"); ConstArrayRef<const char *>::const_iterator i; for (i = bugs_.begin(); i != bugs_.end(); ++i) { const char *const bug = *i; TextLineWrapperSettings settings; settings.setIndent(2); settings.setFirstLineIndent(0); settings.setLineLength(78); context.outputFile().writeLine( context.substituteMarkupAndWrapToString( settings, formatString("* %s", bug))); } }
void TextTableFormatter::addColumnHelpTextBlock( int index, const HelpWriterContext &context, const std::string &text) { Impl::ColumnData &column = impl_->columnData(index); TextLineWrapperSettings settings; if (column.bWrap_) { settings.setLineLength(column.width()); } std::vector<std::string> lines( context.substituteMarkupAndWrapToVector(settings, text)); column.lines_.insert(column.lines_.end(), lines.begin(), lines.end()); }
void AbstractSimpleHelpTopic::writeHelp(const HelpWriterContext &context) const { context.writeTextBlock(helpText()); }
void AbstractCompositeHelpTopic::writeHelp(const HelpWriterContext &context) const { context.writeTextBlock(helpText()); writeSubTopicList(context, "\nAvailable subtopics:"); }
void CommandLineHelpModule::writeHelp(const HelpWriterContext &context) const { context.writeTextBlock( "Usage: [PROGRAM] help [<command>|<topic> [<subtopic> [...]]]"); // TODO: More information. }