Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add support for private/extends/implements. #77

Merged
merged 1 commit into from
Mar 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/Language/Cimple/Ast.hs
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,15 @@ data CommentF lexeme a
| DocAttention [a]
| DocBrief [a]
| DocDeprecated [a]
| DocExtends lexeme
| DocImplements lexeme
| DocParam (Maybe lexeme) lexeme [a]
| DocReturn [a]
| DocRetval lexeme [a]
| DocSee lexeme [a]

| DocPrivate

| DocParagraph [a]
| DocLine [a]
| DocList [a]
Expand Down
5 changes: 5 additions & 0 deletions src/Language/Cimple/CommentParser.y
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ import Language.Cimple.Tokens (LexemeClass (..))
'@attention' { L _ CmtCommand "@attention" }
'@brief' { L _ CmtCommand "@brief" }
'@deprecated' { L _ CmtCommand "@deprecated" }
'@extends' { L _ CmtCommand "@extends" }
'@implements' { L _ CmtCommand "@implements" }
'@param' { L _ CmtCommand "@param" }
'@private' { L _ CmtCommand "@private" }
'@ref' { L _ CmtCommand "@ref" }
'@p' { L _ CmtCommand "@p" }
'@return' { L _ CmtCommand "@return" }
Expand Down Expand Up @@ -137,6 +139,9 @@ Command(x)
| '@return' '\n' BulletListItemII { Fix $ DocReturn (Fix (DocLine []) : $3) }
| '@see' CMT_WORD x { Fix $ DocSee $2 $3 }
| '@deprecated' x { Fix $ DocDeprecated $2 }
| '@implements' CMT_WORD { Fix $ DocImplements $2 }
| '@extends' CMT_WORD { Fix $ DocExtends $2 }
| '@private' { Fix DocPrivate }

BulletListItem :: { NonTerm }
BulletListItem
Expand Down
6 changes: 6 additions & 0 deletions src/Language/Cimple/MapAst.hs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ instance MapAst itext otext (Comment (Lexeme itext)) where
Fix <$> (DocBrief <$> recurse docs)
DocDeprecated docs ->
Fix <$> (DocDeprecated <$> recurse docs)
DocExtends feat ->
Fix <$> (DocExtends <$> recurse feat)
DocImplements feat ->
Fix <$> (DocImplements <$> recurse feat)
DocParam attr name docs ->
Fix <$> (DocParam <$> recurse attr <*> recurse name <*> recurse docs)
DocReturn docs ->
Expand All @@ -131,6 +135,8 @@ instance MapAst itext otext (Comment (Lexeme itext)) where
DocSee ref docs ->
Fix <$> (DocSee <$> recurse ref <*> recurse docs)

DocPrivate -> pure $ Fix DocPrivate

DocParagraph docs ->
Fix <$> (DocParagraph <$> recurse docs)
DocLine docs ->
Expand Down
6 changes: 6 additions & 0 deletions src/Language/Cimple/Pretty.hs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ kwWhile = dullred $ text "while"
kwDocAttention = dullcyan $ text "@attention"
kwDocBrief = dullcyan $ text "@brief"
kwDocDeprecated = dullcyan $ text "@deprecated"
kwDocExtends = dullcyan $ text "@extends"
kwDocImplements = dullcyan $ text "@implements"
kwDocParam = dullcyan $ text "@param"
kwDocPrivate = dullcyan $ text "@private"
kwDocRef = dullcyan $ text "@ref"
kwDocReturn = dullcyan $ text "@return"
kwDocRetval = dullcyan $ text "@retval"
Expand Down Expand Up @@ -298,6 +301,9 @@ ppCommentInfo = foldFix go
DocSee name docs -> kwDocSee <+> ppRef name <+> ppIndented docs
DocRef name -> kwDocRef <+> ppRef name
DocP name -> kwDocP <+> ppRef name
DocExtends feat -> kwDocExtends <+> ppLexeme feat
DocImplements feat -> kwDocImplements <+> ppLexeme feat
DocPrivate -> kwDocPrivate

DocParagraph docs -> ppIndented docs
DocLine docs -> fillSep docs
Expand Down
6 changes: 6 additions & 0 deletions src/Language/Cimple/TraverseAst.hs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ instance TraverseAst text (Comment (Lexeme text)) where
recurse docs
DocDeprecated docs ->
recurse docs
DocExtends feat ->
recurse feat
DocImplements feat ->
recurse feat
DocParam attr name docs -> do
_ <- recurse attr
_ <- recurse name
Expand All @@ -123,6 +127,8 @@ instance TraverseAst text (Comment (Lexeme text)) where
_ <- recurse docs
pure ()

DocPrivate -> pure ()

DocParagraph docs ->
recurse docs
DocLine docs ->
Expand Down