diff --git a/src/solc.ts b/src/solc.ts index e6e0040e..6578a3d7 100644 --- a/src/solc.ts +++ b/src/solc.ts @@ -52,6 +52,7 @@ export namespace ast { nodeType: 'VariableDeclaration'; visibility: 'internal' | 'public' | 'private'; name: string; + documentation: string | null; constant: boolean; typeName: TypeName; } diff --git a/src/source.ts b/src/source.ts index 4c667020..ded254b3 100644 --- a/src/source.ts +++ b/src/source.ts @@ -364,9 +364,13 @@ class SourceStateVariable implements Linkable { return `${this.type} ${this.name}`; } - get natspec(): {} { - warnStateVariableNatspec(); - return {} + @memoize + get natspec(): NatSpec { + if (this.astNode.documentation === null || this.astNode.documentation === undefined) { + return {}; + } + + return parseNatSpec(this.astNode.documentation, this); } } @@ -554,7 +558,7 @@ interface NatSpec { }; } -function parseNatSpec(doc: string, context: SourceFunctionLike | SourceContract): NatSpec { +function parseNatSpec(doc: string, context: SourceFunctionLike | SourceContract | SourceStateVariable): NatSpec { const res: NatSpec = {}; const tagMatches = execall(/^(?:@(\w+|custom:[a-z][a-z-]*) )?((?:(?!^@(?:\w+|custom:[a-z][a-z-]*) )[^])*)/m, doc);