fgerlits commented on code in PR #2097:
URL: https://github.com/apache/nifi-minifi-cpp/pull/2097#discussion_r2896846419
##########
minifi_main/AgentDocs.cpp:
##########
@@ -177,58 +162,161 @@ std::string extractClassName(const std::string&
full_class_name) {
std::string lowercaseFirst(const std::pair<std::string,
minifi::ClassDescription>& key_value) {
return minifi::utils::string::toLower(key_value.first);
-};
+}
-} // namespace
+void writeProcessor(std::ostream& os, const std::string_view name, const
minifi::ClassDescription& documentation) {
+ writeName(os, name);
+ writeDescription(os, documentation);
+ writeProperties(os, documentation);
+ writeDynamicProperties(os, documentation);
+ writeRelationships(os, documentation);
+ writeOutputAttributes(os, documentation);
+}
-namespace org::apache::nifi::minifi::docs {
+void writeControllerService(std::ostream& os, const std::string_view name,
const minifi::ClassDescription& documentation) {
+ writeName(os, name);
+ writeDescription(os, documentation);
+ writeProperties(os, documentation);
+}
-void AgentDocs::generate(const std::filesystem::path& docs_dir) {
- std::vector<std::pair<std::string, minifi::ClassDescription>>
controller_services;
- std::vector<std::pair<std::string, minifi::ClassDescription>> processors;
- std::vector<std::pair<std::string, minifi::ClassDescription>>
parameter_providers;
+void writeParameterProvider(std::ostream& os, const std::string_view name,
const minifi::ClassDescription& documentation) {
+ writeName(os, name);
+ writeDescription(os, documentation);
+ writeProperties(os, documentation);
+}
- for (const auto& [bundle_id, components]:
ClassDescriptionRegistry::getClassDescriptions()) {
- for (const auto &controller_service_description :
components.controller_services) {
+class MonolithDocumentation {
+ public:
+ explicit MonolithDocumentation() {
+ for (const auto& [bundle_id, component]:
minifi::ClassDescriptionRegistry::getClassDescriptions()) {
Review Comment:
The second variable has type `minifi::Components`. Why did you rename it
from `components` to `component`? Please revert this.
##########
minifi_main/AgentDocs.cpp:
##########
@@ -103,7 +95,7 @@ void writeHeader(std::ostream& docs, const
std::vector<std::pair<std::string, mi
docs << APACHE_LICENSE;
docs << "\n\n## Table of Contents\n\n";
- for (const auto& [name, documentation] : class_descriptions) {
+ for (const auto& [name, documentation]: class_descriptions) {
Review Comment:
Why did you remove the spaces before the colons (here and at several other
places in this file)? The Google style guide recommends a space before and
after the colon:
https://google.github.io/styleguide/cppguide.html#Horizontal_Whitespace, and
that's what we have in at least 90% of minifi code, as well. Please put them
back.
##########
minifi_main/AgentDocs.cpp:
##########
@@ -177,58 +162,161 @@ std::string extractClassName(const std::string&
full_class_name) {
std::string lowercaseFirst(const std::pair<std::string,
minifi::ClassDescription>& key_value) {
return minifi::utils::string::toLower(key_value.first);
-};
+}
-} // namespace
+void writeProcessor(std::ostream& os, const std::string_view name, const
minifi::ClassDescription& documentation) {
+ writeName(os, name);
+ writeDescription(os, documentation);
+ writeProperties(os, documentation);
+ writeDynamicProperties(os, documentation);
+ writeRelationships(os, documentation);
+ writeOutputAttributes(os, documentation);
+}
-namespace org::apache::nifi::minifi::docs {
+void writeControllerService(std::ostream& os, const std::string_view name,
const minifi::ClassDescription& documentation) {
+ writeName(os, name);
+ writeDescription(os, documentation);
+ writeProperties(os, documentation);
+}
-void AgentDocs::generate(const std::filesystem::path& docs_dir) {
- std::vector<std::pair<std::string, minifi::ClassDescription>>
controller_services;
- std::vector<std::pair<std::string, minifi::ClassDescription>> processors;
- std::vector<std::pair<std::string, minifi::ClassDescription>>
parameter_providers;
+void writeParameterProvider(std::ostream& os, const std::string_view name,
const minifi::ClassDescription& documentation) {
+ writeName(os, name);
+ writeDescription(os, documentation);
+ writeProperties(os, documentation);
+}
- for (const auto& [bundle_id, components]:
ClassDescriptionRegistry::getClassDescriptions()) {
- for (const auto &controller_service_description :
components.controller_services) {
+class MonolithDocumentation {
+ public:
+ explicit MonolithDocumentation() {
+ for (const auto& [bundle_id, component]:
minifi::ClassDescriptionRegistry::getClassDescriptions()) {
+ addComponents(component);
+ }
+ sort();
+ }
+
+ void write(const std::filesystem::path& docs_dir) {
+ std::ofstream controllers_md(docs_dir / "CONTROLLERS.md");
+ std::ofstream processors_md(docs_dir / "PROCESSORS.md");
+ std::ofstream parameter_providers_md(docs_dir / "PARAMETER_PROVIDERS.md");
+ gsl_Assert(controllers_md && processors_md && parameter_providers_md);
+
+ writeControllers(controllers_md);
+ writeProcessors(processors_md);
+ writeParameterProviders(parameter_providers_md);
+ }
+
+ private:
+ void addComponents(const minifi::Components& components) {
+ for (const auto& controller_service_description:
components.controller_services) {
controller_services.emplace_back(extractClassName(controller_service_description.full_name_),
controller_service_description);
}
- for (const auto &processor_description : components.processors) {
+ for (const auto& processor_description: components.processors) {
processors.emplace_back(extractClassName(processor_description.full_name_),
processor_description);
}
- for (const auto& parameter_provider_description :
components.parameter_providers) {
+ for (const auto& parameter_provider_description:
components.parameter_providers) {
parameter_providers.emplace_back(extractClassName(parameter_provider_description.full_name_),
parameter_provider_description);
}
}
- std::ranges::sort(controller_services, std::less(), lowercaseFirst);
- std::ranges::sort(processors, std::less(), lowercaseFirst);
- std::ranges::sort(parameter_providers, std::less(), lowercaseFirst);
- std::ofstream controllers_md(docs_dir / "CONTROLLERS.md");
- writeHeader(controllers_md, controller_services);
- for (const auto& [name, documentation] : controller_services) {
- writeName(controllers_md, name);
- writeDescription(controllers_md, documentation);
- writeProperties(controllers_md, documentation);
+ void sort() {
+ std::ranges::sort(controller_services, std::less(), lowercaseFirst);
+ std::ranges::sort(processors, std::less(), lowercaseFirst);
+ std::ranges::sort(parameter_providers, std::less(), lowercaseFirst);
+ }
+
+ void writeControllers(std::ostream& os) {
+ writeHeader(os, controller_services);
+ for (const auto& [name, documentation]: controller_services) {
+ writeControllerService(os, name, documentation);
+ }
+ }
+
+ void writeProcessors(std::ostream& os) {
+ writeHeader(os, processors);
+ for (const auto& [name, documentation]: processors) {
+ writeProcessor(os, name, documentation);
+ }
+ }
+
+ void writeParameterProviders(std::ostream& os) {
+ writeHeader(os, parameter_providers);
+ for (const auto& [name, documentation]: parameter_providers) {
+ writeParameterProvider(os, name, documentation);
+ }
+ }
+
+ std::vector<std::pair<std::string, minifi::ClassDescription>>
controller_services;
+ std::vector<std::pair<std::string, minifi::ClassDescription>> processors;
+ std::vector<std::pair<std::string, minifi::ClassDescription>>
parameter_providers;
+};
+
+class ModularDocumentation {
+ public:
+ static void write(const std::filesystem::path& docs_dir) {
+ for (auto& [bundle_id, component]:
minifi::ClassDescriptionRegistry::getMutableClassDescriptions()) {
Review Comment:
does this have to be mutable?
##########
minifi_main/AgentDocs.cpp:
##########
@@ -177,58 +162,161 @@ std::string extractClassName(const std::string&
full_class_name) {
std::string lowercaseFirst(const std::pair<std::string,
minifi::ClassDescription>& key_value) {
return minifi::utils::string::toLower(key_value.first);
-};
+}
-} // namespace
+void writeProcessor(std::ostream& os, const std::string_view name, const
minifi::ClassDescription& documentation) {
+ writeName(os, name);
+ writeDescription(os, documentation);
+ writeProperties(os, documentation);
+ writeDynamicProperties(os, documentation);
+ writeRelationships(os, documentation);
+ writeOutputAttributes(os, documentation);
+}
-namespace org::apache::nifi::minifi::docs {
+void writeControllerService(std::ostream& os, const std::string_view name,
const minifi::ClassDescription& documentation) {
+ writeName(os, name);
+ writeDescription(os, documentation);
+ writeProperties(os, documentation);
+}
-void AgentDocs::generate(const std::filesystem::path& docs_dir) {
- std::vector<std::pair<std::string, minifi::ClassDescription>>
controller_services;
- std::vector<std::pair<std::string, minifi::ClassDescription>> processors;
- std::vector<std::pair<std::string, minifi::ClassDescription>>
parameter_providers;
+void writeParameterProvider(std::ostream& os, const std::string_view name,
const minifi::ClassDescription& documentation) {
+ writeName(os, name);
+ writeDescription(os, documentation);
+ writeProperties(os, documentation);
+}
- for (const auto& [bundle_id, components]:
ClassDescriptionRegistry::getClassDescriptions()) {
- for (const auto &controller_service_description :
components.controller_services) {
+class MonolithDocumentation {
+ public:
+ explicit MonolithDocumentation() {
+ for (const auto& [bundle_id, component]:
minifi::ClassDescriptionRegistry::getClassDescriptions()) {
+ addComponents(component);
+ }
+ sort();
+ }
+
+ void write(const std::filesystem::path& docs_dir) {
+ std::ofstream controllers_md(docs_dir / "CONTROLLERS.md");
+ std::ofstream processors_md(docs_dir / "PROCESSORS.md");
+ std::ofstream parameter_providers_md(docs_dir / "PARAMETER_PROVIDERS.md");
+ gsl_Assert(controllers_md && processors_md && parameter_providers_md);
+
+ writeControllers(controllers_md);
+ writeProcessors(processors_md);
+ writeParameterProviders(parameter_providers_md);
+ }
+
+ private:
+ void addComponents(const minifi::Components& components) {
+ for (const auto& controller_service_description:
components.controller_services) {
controller_services.emplace_back(extractClassName(controller_service_description.full_name_),
controller_service_description);
}
- for (const auto &processor_description : components.processors) {
+ for (const auto& processor_description: components.processors) {
processors.emplace_back(extractClassName(processor_description.full_name_),
processor_description);
}
- for (const auto& parameter_provider_description :
components.parameter_providers) {
+ for (const auto& parameter_provider_description:
components.parameter_providers) {
parameter_providers.emplace_back(extractClassName(parameter_provider_description.full_name_),
parameter_provider_description);
}
}
- std::ranges::sort(controller_services, std::less(), lowercaseFirst);
- std::ranges::sort(processors, std::less(), lowercaseFirst);
- std::ranges::sort(parameter_providers, std::less(), lowercaseFirst);
- std::ofstream controllers_md(docs_dir / "CONTROLLERS.md");
- writeHeader(controllers_md, controller_services);
- for (const auto& [name, documentation] : controller_services) {
- writeName(controllers_md, name);
- writeDescription(controllers_md, documentation);
- writeProperties(controllers_md, documentation);
+ void sort() {
+ std::ranges::sort(controller_services, std::less(), lowercaseFirst);
+ std::ranges::sort(processors, std::less(), lowercaseFirst);
+ std::ranges::sort(parameter_providers, std::less(), lowercaseFirst);
+ }
+
+ void writeControllers(std::ostream& os) {
+ writeHeader(os, controller_services);
+ for (const auto& [name, documentation]: controller_services) {
+ writeControllerService(os, name, documentation);
+ }
+ }
+
+ void writeProcessors(std::ostream& os) {
+ writeHeader(os, processors);
+ for (const auto& [name, documentation]: processors) {
+ writeProcessor(os, name, documentation);
+ }
+ }
+
+ void writeParameterProviders(std::ostream& os) {
+ writeHeader(os, parameter_providers);
+ for (const auto& [name, documentation]: parameter_providers) {
+ writeParameterProvider(os, name, documentation);
+ }
+ }
+
+ std::vector<std::pair<std::string, minifi::ClassDescription>>
controller_services;
+ std::vector<std::pair<std::string, minifi::ClassDescription>> processors;
+ std::vector<std::pair<std::string, minifi::ClassDescription>>
parameter_providers;
+};
+
+class ModularDocumentation {
+ public:
+ static void write(const std::filesystem::path& docs_dir) {
+ for (auto& [bundle_id, component]:
minifi::ClassDescriptionRegistry::getMutableClassDescriptions()) {
+ if (component.empty()) {
+ continue;
+ }
+ sortComponents(component);
+ writeModule(docs_dir, bundle_id.name, component);
+ }
+ }
+
+ private:
+ static void sortComponents(minifi::Components& components) {
+ std::ranges::sort(components.processors, {},
&minifi::ClassDescription::short_name_);
+ std::ranges::sort(components.controller_services, {},
&minifi::ClassDescription::short_name_);
+ std::ranges::sort(components.parameter_providers, {},
&minifi::ClassDescription::short_name_);
Review Comment:
This would put `PutSQL` before `PutSmb`, for example. I don't know if we
currently have two such names within one module, but we might in the future. I
would prefer a case-insensitive sort, unless you have a good reason to prefer
this case-sensitive one.
##########
minifi_main/AgentDocs.cpp:
##########
@@ -177,58 +162,161 @@ std::string extractClassName(const std::string&
full_class_name) {
std::string lowercaseFirst(const std::pair<std::string,
minifi::ClassDescription>& key_value) {
return minifi::utils::string::toLower(key_value.first);
-};
+}
-} // namespace
+void writeProcessor(std::ostream& os, const std::string_view name, const
minifi::ClassDescription& documentation) {
+ writeName(os, name);
+ writeDescription(os, documentation);
+ writeProperties(os, documentation);
+ writeDynamicProperties(os, documentation);
+ writeRelationships(os, documentation);
+ writeOutputAttributes(os, documentation);
+}
-namespace org::apache::nifi::minifi::docs {
+void writeControllerService(std::ostream& os, const std::string_view name,
const minifi::ClassDescription& documentation) {
+ writeName(os, name);
+ writeDescription(os, documentation);
+ writeProperties(os, documentation);
+}
-void AgentDocs::generate(const std::filesystem::path& docs_dir) {
- std::vector<std::pair<std::string, minifi::ClassDescription>>
controller_services;
- std::vector<std::pair<std::string, minifi::ClassDescription>> processors;
- std::vector<std::pair<std::string, minifi::ClassDescription>>
parameter_providers;
+void writeParameterProvider(std::ostream& os, const std::string_view name,
const minifi::ClassDescription& documentation) {
+ writeName(os, name);
+ writeDescription(os, documentation);
+ writeProperties(os, documentation);
+}
- for (const auto& [bundle_id, components]:
ClassDescriptionRegistry::getClassDescriptions()) {
- for (const auto &controller_service_description :
components.controller_services) {
+class MonolithDocumentation {
+ public:
+ explicit MonolithDocumentation() {
+ for (const auto& [bundle_id, component]:
minifi::ClassDescriptionRegistry::getClassDescriptions()) {
+ addComponents(component);
+ }
+ sort();
+ }
+
+ void write(const std::filesystem::path& docs_dir) {
+ std::ofstream controllers_md(docs_dir / "CONTROLLERS.md");
+ std::ofstream processors_md(docs_dir / "PROCESSORS.md");
+ std::ofstream parameter_providers_md(docs_dir / "PARAMETER_PROVIDERS.md");
+ gsl_Assert(controllers_md && processors_md && parameter_providers_md);
+
+ writeControllers(controllers_md);
+ writeProcessors(processors_md);
+ writeParameterProviders(parameter_providers_md);
+ }
+
+ private:
+ void addComponents(const minifi::Components& components) {
+ for (const auto& controller_service_description:
components.controller_services) {
controller_services.emplace_back(extractClassName(controller_service_description.full_name_),
controller_service_description);
}
- for (const auto &processor_description : components.processors) {
+ for (const auto& processor_description: components.processors) {
processors.emplace_back(extractClassName(processor_description.full_name_),
processor_description);
}
- for (const auto& parameter_provider_description :
components.parameter_providers) {
+ for (const auto& parameter_provider_description:
components.parameter_providers) {
parameter_providers.emplace_back(extractClassName(parameter_provider_description.full_name_),
parameter_provider_description);
}
}
- std::ranges::sort(controller_services, std::less(), lowercaseFirst);
- std::ranges::sort(processors, std::less(), lowercaseFirst);
- std::ranges::sort(parameter_providers, std::less(), lowercaseFirst);
- std::ofstream controllers_md(docs_dir / "CONTROLLERS.md");
- writeHeader(controllers_md, controller_services);
- for (const auto& [name, documentation] : controller_services) {
- writeName(controllers_md, name);
- writeDescription(controllers_md, documentation);
- writeProperties(controllers_md, documentation);
+ void sort() {
+ std::ranges::sort(controller_services, std::less(), lowercaseFirst);
+ std::ranges::sort(processors, std::less(), lowercaseFirst);
+ std::ranges::sort(parameter_providers, std::less(), lowercaseFirst);
+ }
+
+ void writeControllers(std::ostream& os) {
+ writeHeader(os, controller_services);
+ for (const auto& [name, documentation]: controller_services) {
+ writeControllerService(os, name, documentation);
+ }
+ }
+
+ void writeProcessors(std::ostream& os) {
+ writeHeader(os, processors);
+ for (const auto& [name, documentation]: processors) {
+ writeProcessor(os, name, documentation);
+ }
+ }
+
+ void writeParameterProviders(std::ostream& os) {
+ writeHeader(os, parameter_providers);
+ for (const auto& [name, documentation]: parameter_providers) {
+ writeParameterProvider(os, name, documentation);
+ }
+ }
+
+ std::vector<std::pair<std::string, minifi::ClassDescription>>
controller_services;
+ std::vector<std::pair<std::string, minifi::ClassDescription>> processors;
+ std::vector<std::pair<std::string, minifi::ClassDescription>>
parameter_providers;
+};
+
+class ModularDocumentation {
+ public:
+ static void write(const std::filesystem::path& docs_dir) {
+ for (auto& [bundle_id, component]:
minifi::ClassDescriptionRegistry::getMutableClassDescriptions()) {
Review Comment:
I would name this `components`, as well
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]