From 401400cbcd276703f9767bac2affc3999f1fdeab Mon Sep 17 00:00:00 2001 From: Pieter Hijma Date: Fri, 17 Oct 2025 15:19:14 +0200 Subject: [PATCH] Doc: Apply cog to Link.h and Link.cpp Cog is reapplied to create improved documentation for LinkParams. See LinkParams.py --- src/App/Link.cpp | 97 ++++++++++++++++----------------------- src/App/Link.h | 38 +++++++-------- src/Tools/params_utils.py | 12 +++-- 3 files changed, 66 insertions(+), 81 deletions(-) diff --git a/src/App/Link.cpp b/src/App/Link.cpp index b94a96f4ce..7aa0a98f87 100644 --- a/src/App/Link.cpp +++ b/src/App/Link.cpp @@ -61,104 +61,85 @@ import LinkParams LinkParams.define() ]]]*/ -namespace -{ - -// Auto generated code. See class document of LinkParams. -class LinkParamsP: public ParameterGrp::ObserverType -{ +// Auto generated code (App/params_utils.py:209) +namespace { +class LinkParamsP: public ParameterGrp::ObserverType { public: - // Auto generated code. See class document of LinkParams. ParameterGrp::handle handle; + std::unordered_map funcs; - // Auto generated code. See class document of LinkParams. - std::unordered_map - funcs; + bool CopyOnChangeApplyToAll; - bool CopyOnChangeApplyToAll; // Auto generated code. See class document of LinkParams. - - // Auto generated code. See class document of LinkParams. - LinkParamsP() - { - handle = App::GetApplication().GetParameterGroupByPath( - "User parameter:BaseApp/Preferences/Link"); + // Auto generated code (App/params_utils.py:247) + LinkParamsP() { + handle = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Link"); handle->Attach(this); CopyOnChangeApplyToAll = handle->GetBool("CopyOnChangeApplyToAll", true); funcs["CopyOnChangeApplyToAll"] = &LinkParamsP::updateCopyOnChangeApplyToAll; } - // Auto generated code. See class document of LinkParams. - ~LinkParamsP() override = default; + // Auto generated code (App/params_utils.py:265) + ~LinkParamsP() { + } - // Auto generated code. See class document of LinkParams. - void OnChange(Base::Subject&, const char* sReason) override - { - if (!sReason) { + // Auto generated code (App/params_utils.py:272) + void OnChange(Base::Subject &, const char* sReason) { + if(!sReason) return; - } auto it = funcs.find(sReason); - if (it == funcs.end()) { + if(it == funcs.end()) return; - } it->second(this); + } - // Auto generated code. See class document of LinkParams. - static void updateCopyOnChangeApplyToAll(LinkParamsP* self) - { + // Auto generated code (App/params_utils.py:290) + static void updateCopyOnChangeApplyToAll(LinkParamsP *self) { self->CopyOnChangeApplyToAll = self->handle->GetBool("CopyOnChangeApplyToAll", true); } }; -// Auto generated code. See class document of LinkParams. -LinkParamsP* instance() -{ - static LinkParamsP* inst = new LinkParamsP; +// Auto generated code (App/params_utils.py:312) +LinkParamsP *instance() { + static LinkParamsP *inst = new LinkParamsP; return inst; } -} // Anonymous namespace +} // Anonymous namespace -// Auto generated code. See class document of LinkParams. -ParameterGrp::handle LinkParams::getHandle() -{ +// Auto generated code (App/params_utils.py:323) +ParameterGrp::handle LinkParams::getHandle() { return instance()->handle; } -// Auto generated code. See class document of LinkParams. -const char* LinkParams::docCopyOnChangeApplyToAll() -{ - return QT_TRANSLATE_NOOP( - "LinkParams", - "Stores the last user choice of whether to apply CopyOnChange setup to all links\n" - "that reference the same configurable object"); +// Auto generated code (App/params_utils.py:352) +const char *LinkParams::docCopyOnChangeApplyToAll() { + return QT_TRANSLATE_NOOP("LinkParams", +"Stores the last user choice of whether to apply CopyOnChange setup to all link\n" +"that links to the same configurable object"); } -// Auto generated code. See class document of LinkParams. -const bool& LinkParams::getCopyOnChangeApplyToAll() -{ +// Auto generated code (App/params_utils.py:360) +const bool & LinkParams::getCopyOnChangeApplyToAll() { return instance()->CopyOnChangeApplyToAll; } -// Auto generated code. See class document of LinkParams. -const bool& LinkParams::defaultCopyOnChangeApplyToAll() -{ - static const bool def = true; +// Auto generated code (App/params_utils.py:368) +const bool & LinkParams::defaultCopyOnChangeApplyToAll() { + const static bool def = true; return def; } -// Auto generated code. See class document of LinkParams. -void LinkParams::setCopyOnChangeApplyToAll(const bool& v) -{ - instance()->handle->SetBool("CopyOnChangeApplyToAll", v); +// Auto generated code (App/params_utils.py:377) +void LinkParams::setCopyOnChangeApplyToAll(const bool &v) { + instance()->handle->SetBool("CopyOnChangeApplyToAll",v); instance()->CopyOnChangeApplyToAll = v; } -// Auto generated code. See class document of LinkParams. -void LinkParams::removeCopyOnChangeApplyToAll() -{ +// Auto generated code (App/params_utils.py:386) +void LinkParams::removeCopyOnChangeApplyToAll() { instance()->handle->RemoveBool("CopyOnChangeApplyToAll"); } //[[[end]]] diff --git a/src/App/Link.h b/src/App/Link.h index 22c604ee77..b99293a507 100644 --- a/src/App/Link.h +++ b/src/App/Link.h @@ -1146,13 +1146,14 @@ import LinkParams LinkParams.declare() ]]]*/ -namespace App -{ -/** Convenient class to obtain App::Link related parameters - +// Auto generated code (App/params_utils.py:90) +namespace App { +/** + * @brief Convenient class to obtain App::Link related parameters + * * The parameters are under group "User parameter:BaseApp/Preferences/Link" * - * This class is auto generated by LinkParams.py. Modify that file + * This class is auto generated by App/LinkParams.py. Modify that file * instead of this one, if you want to add any parameter. You need * to install Cog Python package for code generation: * @code @@ -1164,7 +1165,7 @@ namespace App * python3 -m cogapp -r Link.h Link.cpp * @endcode * - * You can add a new parameter by adding lines in LinkParams.py. Available + * You can add a new parameter by adding lines in App/LinkParams.py. Available * parameter types are 'Int, UInt, String, Bool, Float'. For example, to add * a new Int type parameter, * @code @@ -1178,26 +1179,27 @@ namespace App * void LinkParams:onChanged() * @endcode */ -class AppExport LinkParams -{ +class AppExport LinkParams { public: static ParameterGrp::handle getHandle(); - //@{ - /// Accessor for parameter CopyOnChangeApplyToAll + // Auto generated code (App/params_utils.py:139) + /// @name CopyOnChangeApplyToAll accessors + /// @brief Accessors for parameter CopyOnChangeApplyToAll /// /// Stores the last user choice of whether to apply CopyOnChange setup to all link /// that links to the same configurable object - static const bool& getCopyOnChangeApplyToAll(); - static const bool& defaultCopyOnChangeApplyToAll(); + /// @{ + static const bool & getCopyOnChangeApplyToAll(); + static const bool & defaultCopyOnChangeApplyToAll(); static void removeCopyOnChangeApplyToAll(); - static void setCopyOnChangeApplyToAll(const bool& v); - static const char* docCopyOnChangeApplyToAll(); - //@} + static void setCopyOnChangeApplyToAll(const bool &v); + static const char *docCopyOnChangeApplyToAll(); + /// @} - // Auto generated code. See class document of LinkParams. -}; -} // namespace App +// Auto generated code (App/params_utils.py:180) +}; // class LinkParams +} // namespace App //[[[end]]] diff --git a/src/Tools/params_utils.py b/src/Tools/params_utils.py index c6b3cd22ff..722e59392e 100644 --- a/src/Tools/params_utils.py +++ b/src/Tools/params_utils.py @@ -90,8 +90,9 @@ def declare_begin(module, header=True): f""" {trace_comment()} namespace {namespace} {{ -/** {class_doc} - +/** + * @brief {class_doc} + * * The parameters are under group "{param_path}" * * This class is auto generated by {param_file}. Modify that file @@ -137,8 +138,8 @@ public: cog.out( f""" {trace_comment()} - //@{{ - /// Accessor for parameter {param.name}""" + /// @name {param.name} accessors + /// @brief Accessors for parameter {param.name}""" ) if param._doc: cog.out( @@ -152,6 +153,7 @@ public: ) cog.out( f""" + /// @{{ static const {param.C_Type} & get{param.name}(); static const {param.C_Type} & default{param.name}(); static void remove{param.name}(); @@ -165,7 +167,7 @@ public: ) cog.out( f""" - //@}} + /// @}} """ )