-
-
Notifications
You must be signed in to change notification settings - Fork 42
Expand file tree
/
Copy pathDocSetManager.h
More file actions
77 lines (63 loc) · 2.78 KB
/
Copy pathDocSetManager.h
File metadata and controls
77 lines (63 loc) · 2.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
//
// Created by Ivan Buhov on 11/6/15.
//
#ifndef METADATAGENERATOR_DOCSETPARSER_H
#define METADATAGENERATOR_DOCSETPARSER_H
#include <Meta/MetaEntities.h>
struct _xmlDoc;
namespace Meta {
class Meta;
}
namespace TypeScript {
// \brief A structure, representing a TypeScript comment.
struct TSComment {
/*
* \brief A brief description of the symbol.
*/
std::string description;
/*
* \brief An optional list of parameters. Useful in method and function comments.
*/
std::vector<std::pair<std::string, std::string> > params;
/*
* \brief An optional list of field comments. Useful in struct and union comments.
*/
std::vector<TSComment> fields;
/*
* \brief Converts the comment into its string representation.
* \param linePrefix Will prefix every line in the output with this value. Useful in case of tabulation.
*/
std::string toString(std::string linePrefix);
};
/*
* \class DocSetManager
* \brief The DocSetManager is responsible for parsing and retrieving documentation from .docset packages. It parses the XML files in the .docset and generates TypeScript comments from them.
*/
class DocSetManager {
public:
DocSetManager(std::string docsetPath)
: docsetPath(docsetPath)
, tokensPath(docsetPath + "/Contents/Resources/Tokens")
{
}
/*
* \brief Retrieves a TypeScript comment for a given symbol. If the symbol is a member (e.g. method or property) a parent must be supplied, too.
* \param meta The symbol for which TypeScript comment will be generated.
* \param parent If the first parameter is method or property, a parent (the containing Interface or Protocol) must be passed, too, in order to find the correct XML file location.
*/
TSComment getCommentFor(Meta::Meta* meta, Meta::Meta* parent = nullptr);
TSComment getCommentFor(std::string name, Meta::MetaType type, std::string parentName = "", Meta::MetaType parentType = Meta::MetaType::Undefined);
private:
/*
* \brief Tries to find the location and parses the XML documentation file for a symbol with the given name and type. Null is returned if unable to find a doc file.
* \param name The name of the symbol.
* \param type The type of the symbol. Depending on the type, different foldeers will be examined.
* \param parentName If the symbol is method or property, a parent (the containing Interface or Protocol) must be passed, too, in order to find the correct XML file location.
* \param parentType The type of the parent symbol.
*/
_xmlDoc* getXmlDocFileFor(std::string name, Meta::MetaType type, std::string parentName = "", Meta::MetaType parentType = Meta::MetaType::Undefined);
std::string docsetPath;
std::string tokensPath;
};
}
#endif //METADATAGENERATOR_DOCSETPARSER_H