MCPcopy Create free account
hub / github.com/LibreSprite/LibreSprite / documentation

Method documentation

src/app/script/api/app_script.cpp:141–217  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

139 }
140
141 void documentation() {
142 std::stringstream out;
143 if (!this->get("activeDocument")) {
144 return;
145 }
146
147 auto& internalRegistry = script::InternalScriptObject::getRegistry();
148 auto originalDefault = internalRegistry[""];
149 script::InternalScriptObject::setDefault("DudScriptObject");
150
151 for (auto& entry : script::ScriptObject::getRegistry()) {
152 if (entry.first.empty())
153 continue;
154 inject<ScriptObject> so{entry.first};
155 auto internal = dynamic_cast<DudScriptObject*>(so->getInternalScriptObject());
156 if (!internal)
157 continue;
158
159 out << "# ";
160 if (!internal->globalName.empty())
161 out << "global " << internal->globalName << " ";
162
163 std::string className = entry.first;
164 auto dot = className.rfind("ScriptObject");
165 if (dot != std::string::npos)
166 className.resize(dot);
167
168 out << "[class " << className << "]" << std::endl;
169
170 if (internal->properties.empty()) {
171 out << "## No Properties." << std::endl;
172 } else {
173 out << "## Properties: " << std::endl;
174 for (auto& propEntry : internal->properties) {
175 auto& prop = propEntry.second;
176 out << " - `" << propEntry.first << "`: " << prop.docStr << std::endl;
177 }
178 }
179
180 out << std::endl;
181
182 if (internal->functions.empty()) {
183 out << "## No Methods." << std::endl;
184 } else {
185 out << "## Methods: " << std::endl;
186 for (auto& funcEntry : internal->functions) {
187 auto& func = funcEntry.second;
188 out << " - `" << funcEntry.first << "(";
189 bool first = true;
190 for (auto& arg : func.docArgs) {
191 if (!first) out << ", ";
192 first = false;
193 out << arg.name;
194 }
195 out << ")`: " << std::endl;
196
197 for (auto& arg : func.docArgs) {
198 out << " - " << arg.name << ": " << arg.docStr << std::endl;

Callers

nothing calls this directly

Calls 5

getMethod · 0.45
emptyMethod · 0.45
resizeMethod · 0.45
strMethod · 0.45

Tested by

no test coverage detected