Skip to content

Commit 747c18e

Browse files
committed
added property support for api doc
1 parent 3b5d817 commit 747c18e

File tree

13 files changed

+203
-107
lines changed

13 files changed

+203
-107
lines changed

src/engraving/api/v1/elements.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2356,17 +2356,22 @@ class Tie : public Spanner
23562356
/// \endcond
23572357
};
23582358

2359+
/** APIDOC
2360+
* Class representing a lyric.
2361+
* @class Lyric
2362+
* @hideconstructor
2363+
*/
23592364
class Lyric : public EngravingItem
23602365
{
23612366
Q_OBJECT
2362-
23632367
Q_PROPERTY(QString plainText READ plainText)
23642368

23652369
public:
23662370

23672371
Lyric(mu::engraving::Lyrics* l = nullptr, Ownership own = Ownership::PLUGIN)
23682372
: EngravingItem(l, own) {}
23692373

2374+
/** APIDOC @property {string} - plain text of lyric */
23702375
QString plainText() const { return toLyrics(e)->plainText(); }
23712376
};
23722377

src/engraving/api/v1/score.cpp

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,18 @@
3939

4040
using namespace mu::engraving::apiv1;
4141

42+
/** APIDOC
43+
* Class representing a score.
44+
* We can get the current score by calling the `api.engraving.curScore`
45+
* @class Score
46+
* @hideconstructor
47+
*/
48+
49+
/** APIDOC
50+
* Create a new Cursor
51+
* @method
52+
* @returns {Cursor} cursor
53+
*/
4254
Cursor* Score::newCursor()
4355
{
4456
return new Cursor(score());
@@ -262,12 +274,35 @@ QQmlListProperty<System> Score::systems()
262274
return wrapContainerProperty<System>(this, score()->systems());
263275
}
264276

265-
QQmlListProperty<Lyric> Score::lyrics()
277+
/** APIDOC @property {boolean} - has lyrics */
278+
bool Score::hasLyrics() const
279+
{
280+
return score()->hasLyrics();
281+
}
282+
283+
/** APIDOC @property {number} - count of lyrics */
284+
int Score::lyricCount() const
285+
{
286+
return score()->lyricCount();
287+
}
288+
289+
/** APIDOC @property {Lyric[]} - list of lyrics */
290+
QQmlListProperty<Lyric> Score::lyrics() const
266291
{
267292
static std::vector<Lyrics*> list = score()->lyrics();
268293
return wrapContainerProperty<Lyric>(this, list);
269294
}
270295

296+
/** APIDOC
297+
* Extracts all lyrics in the score and returns them in a single string.
298+
* @method
299+
* @return {string} - lyrics string
300+
*/
301+
QString Score::extractLyrics() const
302+
{
303+
return score()->extractLyrics();
304+
}
305+
271306
//---------------------------------------------------------
272307
// Score::startCmd
273308
//---------------------------------------------------------

src/engraving/api/v1/score.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -273,11 +273,10 @@ class Score : public apiv1::ScoreElement, public muse::Injectable
273273
Q_INVOKABLE apiv1::Segment* findSegmentAtTick(int types, apiv1::FractionWrapper* tick);
274274

275275
// === Lyrics ===
276-
bool hasLyrics() { return score()->hasLyrics(); }
277-
int lyricCount() { return score()->lyricCount(); }
278-
QQmlListProperty<apiv1::Lyric> lyrics();
279-
/// Extracts all lyrics in the score and returns them in a single string.
280-
Q_INVOKABLE QString extractLyrics() { return score()->extractLyrics(); }
276+
bool hasLyrics() const;
277+
int lyricCount() const;
278+
QQmlListProperty<apiv1::Lyric> lyrics() const;
279+
Q_INVOKABLE QString extractLyrics() const;
281280

282281
/// \cond MS_INTERNAL
283282
int nmeasures() const { return static_cast<int>(score()->nmeasures()); }

src/engraving/api/v1/scoreelement.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,8 @@ class QmlListAccess : public QQmlListProperty<T>
183183

184184
/// \cond PLUGIN_API \private \endcond
185185
template<typename T, class Container>
186-
QmlListAccess<T, Container> wrapContainerProperty(QObject* obj, Container& c)
186+
QmlListAccess<T, Container> wrapContainerProperty(const QObject* obj, Container& c)
187187
{
188-
return QmlListAccess<T, Container>(obj, c);
188+
return QmlListAccess<T, Container>(const_cast<QObject*>(obj), c);
189189
}
190190
}

src/engraving/dom/score.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4995,7 +4995,7 @@ ChordRest* Score::cmdTopStaff(ChordRest* cr)
49954995
// hasLyrics
49964996
//---------------------------------------------------------
49974997

4998-
bool Score::hasLyrics()
4998+
bool Score::hasLyrics() const
49994999
{
50005000
if (!firstMeasure()) {
50015001
return false;
@@ -5017,7 +5017,7 @@ bool Score::hasLyrics()
50175017
// hasHarmonies
50185018
//---------------------------------------------------------
50195019

5020-
bool Score::hasHarmonies()
5020+
bool Score::hasHarmonies() const
50215021
{
50225022
if (!firstMeasure()) {
50235023
return false;
@@ -5117,7 +5117,7 @@ std::vector<Lyrics*> Score::lyrics() const
51175117
// extractLyrics
51185118
//---------------------------------------------------------
51195119

5120-
String Score::extractLyrics()
5120+
String Score::extractLyrics() const
51215121
{
51225122
String result;
51235123
std::vector<Lyrics*> list = lyrics();
@@ -5133,12 +5133,11 @@ String Score::extractLyrics()
51335133
return result.trimmed();
51345134
}
51355135

5136-
51375136
//---------------------------------------------------------
51385137
// harmonyCount
51395138
//---------------------------------------------------------
51405139

5141-
int Score::harmonyCount()
5140+
int Score::harmonyCount() const
51425141
{
51435142
int count = 0;
51445143
SegmentType st = SegmentType::ChordRest;
@@ -5152,7 +5151,6 @@ int Score::harmonyCount()
51525151
return count;
51535152
}
51545153

5155-
51565154
//---------------------------------------------------------
51575155
// keysig
51585156
//---------------------------------------------------------

src/engraving/dom/score.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -990,12 +990,15 @@ class Score : public EngravingObject, public muse::Injectable
990990
EngravingItem* lastElement(bool frame = true);
991991

992992
size_t nmeasures() const;
993-
bool hasLyrics();
994-
bool hasHarmonies();
993+
994+
bool hasHarmonies() const;
995+
int harmonyCount() const;
996+
997+
bool hasLyrics() const;
995998
int lyricCount() const;
996999
std::vector<Lyrics*> lyrics() const;
997-
int harmonyCount();
998-
String extractLyrics();
1000+
String extractLyrics() const;
1001+
9991002
int keysig();
10001003
int duration();
10011004
int durationWithoutRepeats();

src/framework/global/api/interactiveapi.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,19 @@
2525

2626
using namespace muse::api;
2727

28-
/** APIDOC namespace: interactive
28+
/** APIDOC
2929
* User interaction - informational messages, error messages, questions and other dialogs.
30-
* @namespace
30+
* @namespace interactive
3131
*/
3232

3333
InteractiveApi::InteractiveApi(IApiEngine* e)
3434
: ApiObject(e)
3535
{
3636
}
3737

38-
/** APIDOC method
38+
/** APIDOC
3939
* Show information message
40+
* @method
4041
* @param {String} title Title
4142
* @param {String} text Message
4243
*/
@@ -46,8 +47,9 @@ void InteractiveApi::info(const QString& contentTitle, const QString& text)
4647
interactive()->infoSync(contentTitle.toStdString(), text.toStdString());
4748
}
4849

49-
/** APIDOC method
50+
/** APIDOC
5051
* Open URL in external browser
52+
* @method
5153
* @param {String} url URL
5254
*/
5355
void InteractiveApi::openUrl(const QString& url)

src/framework/global/api/logapi.cpp

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,53 +25,58 @@
2525

2626
using namespace muse::api;
2727

28-
/** APIDOC namespace: log
28+
/** APIDOC
2929
* Write messages to log and console
30-
* @namespace
30+
* @namespace log
3131
*/
3232
LogApi::LogApi(api::IApiEngine* e)
3333
: ApiObject(e)
3434
{
3535
}
3636

37-
/** APIDOC method
37+
/** APIDOC
3838
* Write error message with default tag
39+
* @method
3940
* @param {String} message Message
4041
*/
4142
void LogApi::error(const QString& message)
4243
{
4344
error("Api", message);
4445
}
4546

46-
/** APIDOC method
47+
/** APIDOC
4748
* Write warning message with default tag
49+
* @method
4850
* @param {String} message Message
4951
*/
5052
void LogApi::warn(const QString& message)
5153
{
5254
warn("Api", message);
5355
}
5456

55-
/** APIDOC method
57+
/** APIDOC
5658
* Write info message with default tag
59+
* @method
5760
* @param {String} message Message
5861
*/
5962
void LogApi::info(const QString& message)
6063
{
6164
info("Api", message);
6265
}
6366

64-
/** APIDOC method
67+
/** APIDOC
6568
* Write debug message with default tag
69+
* @method
6670
* @param {String} message Message
6771
*/
6872
void LogApi::debug(const QString& message)
6973
{
7074
debug("Api", message);
7175
}
7276

73-
/** APIDOC method
77+
/** APIDOC
7478
* Write error message with tag
79+
* @method
7580
* @param {String} tag Tag
7681
* @param {String} message Message
7782
*/
@@ -80,8 +85,9 @@ void LogApi::error(const QString& tag, const QString& message)
8085
LOGE_T(tag.toStdString())() << message;
8186
}
8287

83-
/** APIDOC method
88+
/** APIDOC
8489
* Write warning message with tag
90+
* @method
8591
* @param {String} tag Tag
8692
* @param {String} message Message
8793
*/
@@ -90,8 +96,9 @@ void LogApi::warn(const QString& tag, const QString& message)
9096
LOGW_T(tag.toStdString())() << message;
9197
}
9298

93-
/** APIDOC method
99+
/** APIDOC
94100
* Write info message with tag
101+
* @method
95102
* @param {String} tag Tag
96103
* @param {String} message Message
97104
*/
@@ -100,8 +107,9 @@ void LogApi::info(const QString& tag, const QString& message)
100107
LOGI_T(tag.toStdString())() << message;
101108
}
102109

103-
/** APIDOC method
110+
/** APIDOC
104111
* Write debug message with tag
112+
* @method
105113
* @param {String} tag Tag
106114
* @param {String} message Message
107115
*/

tools/jsdoc/.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
node_modules
2-
package.json
32
package-lock.json
43
out
54
gen_apidocsrc

0 commit comments

Comments
 (0)