From a7718544d8ff5c36f436bfa68a623c610d15a2b1 Mon Sep 17 00:00:00 2001 From: rolux Date: Thu, 18 Dec 2014 14:25:02 +0000 Subject: [PATCH] update api docs parser --- static/js/apiDialog.js | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/static/js/apiDialog.js b/static/js/apiDialog.js index 2a1497731..876021722 100644 --- a/static/js/apiDialog.js +++ b/static/js/apiDialog.js @@ -131,39 +131,42 @@ pandora.ui.apiDialog = function() { var $doc = Ox.SyntaxHighlighter({ source: string.replace( /\n(?=(takes \{|returns \{|note: |see: ))/g, '\n\n' + ).replace( + /(takes|returns|note|see)(?=( \{|: ))/g, 'BOLD$1BOLD' + ).replace( + /`/g, 'BOLD' ) }) .css({backgroundColor: 'rgba(0, 0, 0, 0)'}), - parts, parts_; + parts, parts_, + str = ',' + + ' '; ['Keyword', 'Method', 'Property'].forEach(function(type) { $doc.find('.Ox' + type).removeClass('Ox' + type); }); Ox.print('DEBUG', $doc.html()) $doc.html( - $doc.html() - .replace(/(takes \{|returns \{|note: |see: )/g, '$1') - .replace(/`(?=\w)/g, '') - .replace(/`(?=\W)/g, '') + $doc.html().replace(/X(\w+)X/g, '$1') ); - parts = $doc.html().split('notes: '); + parts = $doc.html().split('notes'); if (parts.length == 2) { - parts_ = parts[1].split('see: '); + parts_ = parts[1].split('see'); if (len(parts_) == 2) { parts_[0] = parts_[0].replace(/\n\s+?/g, ' '); - parts[1] = parts_.join('see: '); + parts[1] = parts_.join('see'); } else { parts[1] = parts[1].replace(/\n\s+?/g, ' '); } - $doc.html(parts.join('notes: ')); + $doc.html(parts.join('notes')); } - parts = $doc.html().split('see: '); + parts = $doc.html().split('see'); if (parts.length == 2) { - parts[1] = parts[1].replace(/\n\s+?/, '').split(', ').map( + parts[1] = parts[1].replace(/\n\s+?/, '').split(str).map( function(action) { return '' + action + ''; } - ).join(', '); - $doc.html(parts.join('see: ')); + ).join(str); + $doc.html(parts.join('see')); } pandora.createLinks($doc); return $doc;