From 7139830e003a7c50ffd465c3d41869c430d74a83 Mon Sep 17 00:00:00 2001 From: Rene Saarsoo Date: Tue, 18 Dec 2012 09:56:42 +0200 Subject: [PATCH] Refactor @inheritdoc implementation. Extract parts of the parsing routine into separate methods so that the #at_inheritdoc method works at a more higher level. --- lib/jsduck/doc_parser.rb | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/lib/jsduck/doc_parser.rb b/lib/jsduck/doc_parser.rb index 105f2abd..12061a64 100644 --- a/lib/jsduck/doc_parser.rb +++ b/lib/jsduck/doc_parser.rb @@ -212,24 +212,8 @@ module JsDuck # matches @inheritdoc class.name#static-type-member def at_inheritdoc add_tag(:inheritdoc) - skip_horiz_white - - if look(@ident_chain_pattern) - @current_tag[:cls] = ident_chain - end - - if look(/#\w/) - match(/#/) - if look(/static-/) - @current_tag[:static] = true - match(/static-/) - end - if look(/(cfg|property|method|event|css_var|css_mixin)-/) - @current_tag[:type] = ident.to_sym - match(/-/) - end - @current_tag[:member] = ident - end + maybe_ident_chain(:cls) + maybe_member_reference end # @@ -315,6 +299,23 @@ module JsDuck end end + # matches a member reference: "#" "-" "-" + # setting the corresponding properties on @current_tag + def maybe_member_reference + if look(/#\w/) + match(/#/) + if look(/static-/) + @current_tag[:static] = true + match(/static-/) + end + if look(/(cfg|property|method|event|css_var|css_mixin)-/) + @current_tag[:type] = ident.to_sym + match(/-/) + end + @current_tag[:member] = ident + end + end + # Attempts to allow balanced braces in default value. # When the nested parsing doesn't finish at closing "]", # roll back to beginning and simply grab anything up to closing "]". -- GitLab