|
From: SourceForge.net <no...@so...> - 2012-02-15 09:00:26
|
Patches item #3487782, was opened at 2012-02-15 01:00 Message generated for change (Tracker Item Submitted) made by vcejka You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=304213&aid=3487782&group_id=4213 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: VCejka (vcejka) Assigned to: Nobody/Anonymous (nobody) Summary: Support for attributes Initial Comment: Attributes were added to Delphi since v2010, but their present in the source code caused PasDoc to fail. This patch adds support for finding them and generate their documentation in HTML generator. Attributes are quite complex and their syntax can be easily mixed with other pascal syntax elements, like enumeration. I tested them on some medium scale project (<100 units), but still I'm not sure if I chekced everything. So if you find some bug, please make a report and contact me. Suppose this patch as a beta release. If it will be accepted, support for other generators etc. can be added. Because of generator, there should be update of language files preformed for "Attributes" string. There is a list of souce code modification with short explanation of implementation: Changes to PasDoc: Items: - To TPasItem added property Attributes as TStringPairVector containing list of attributes defined for this item. Name property containt attribute class name, Value property contains parameters. Method SetAttributes is added, it assigns given string pair vector to PasItem and creates new one returning it back in var param Parser: - added private boolean field AttributeIsPossible to Tparser - added private field CurrentAttributes (TStringPairVector) to Tparser, created in constructor and destroyed in destructor - Attributes are found in square brackets before item. If parser finds them, stores them to CurrentAttributes field and then moves them to Attributes property of appropriate TPasItem - Detected attributes: o Of constructor, destructor, function or procedure of class or record – in ParseCDFP, set to TPasMethod o Of Constant – in ParseConstant, set to TPasConstant o Of Enum – in ParseEnum, set to TPasEnum o Of property of class or record – in ParseProperty, set to TPasProperty o Of case field of class or record – in ParseRecordCase, set to TPasFieldVariable o Of field of class or record – in ParseFieldsVariables, set to TpasFieldVariable o Of class or record declaration – in ParseCioTypeDecl, set to TPasCio o Of any type – in ParseType, set to TPasType - in current Delphi implementation Constants cannot have attributes defined, but parser handles it - it is not possible to apply attributes to variant cases of record fields, so parsing is temporalily disabled and then restored to original state (TParser.ParseRecordCase). - Parsing of attributes is disabled when interface section of some unit is entered and enabled when some type keyword occurs (TParser.ParseInterfaceSection) - Parsing of attributes is disabled when new type identifier is found and type definition is expected (TParser.ParseType), but it is enabled again when identifier declaration is parsed (TParser.ParseInterfaceSection) - Parsing of attributes is temporalily disabled when skipping declaration (TParser.SkipDeclaration) - When attribute is possible, it is extracted by TParser.PeekNextToken. When identifier is found, there can be no attribute, so checking is disabled until next semicolon. When attribute is possible, left square bracket is checked. If found, tokens until next right squate bracket are taken as attribute. There might be square brackets as part of attribute parameres, i.e. sets, so inner brackets are ignored. There can be more attributes defined in 1 pair of square brackets, separated by comma, but comma can also separate parameters of attribute. When comma is used inside parenthesis, it is understood as parameter separator, otherwise it is used as attribute separator. - When members of class, interface or object are analysed, it is supposed that attribute can be just in front of keyword or identifier, so checking is enabled at the beginning, token is taken and attributes checking is disabled again (TParser.ParseCioMembers). When end directive occurs (end of CIO), attributes, even if found and not used, are cleared. - Also when CIO type declaration is parsed, parsing of attributes is enabled at the beginning, token is taken and parsing of attributes is disabled. - Internal types of CIO are not parsed for attributes at this moment!!! Should it be added? - When square bratcket is found in TParser.PeekNextToken but string follows instead of identifier, it is not supposed to be attribute, but GUID. It is also added as attribute with fake attribute class name GUID GetHtml: - Added WriteAttributes procedure to TGenericHTMLDocGenerator .WriteItemLongDescription Languages: - added item trAttributes to TtranslationID enumeration. Translation must be added to lang/*.inc files, added to english and czech translation files, all other set to „ToDo“ string - style „attributes“ can be added to *.css for HTMLDocGenerator ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=304213&aid=3487782&group_id=4213 |