Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(93)

Issue 9225039: Integrate MDN content into API documentation. (Closed)

Created:
8 years, 11 months ago by Bob Nystrom
Modified:
8 years, 10 months ago
Reviewers:
nweiz, Jacob
CC:
reviews_dartlang.org
Visibility:
Public.

Description

Integrate MDN content into API documentation. Most of the code under mdn/ is Jacob's magic with a little extra hackery on my part. Committed: https://code.google.com/p/dart/source/detail?r=3750

Patch Set 1 #

Patch Set 2 : Remove temp code. #

Total comments: 296

Patch Set 3 : Respond to review. #

Patch Set 4 : Respond to review. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+2562 lines, -105 lines) Patch
M utils/apidoc/.gitignore View 1 2 3 1 chunk +2 lines, -1 line 0 comments Download
M utils/apidoc/apidoc View 1 2 3 2 chunks +5 lines, -3 lines 0 comments Download
M utils/apidoc/apidoc.dart View 1 2 3 3 chunks +275 lines, -93 lines 0 comments Download
A utils/apidoc/mdn/README.txt View 1 2 3 1 chunk +48 lines, -0 lines 0 comments Download
A utils/apidoc/mdn/crawl.js View 1 2 3 1 chunk +117 lines, -0 lines 0 comments Download
A utils/apidoc/mdn/data/dartIdl.json View 1 2 3 1 chunk +1 line, -0 lines 0 comments Download
A utils/apidoc/mdn/data/domTypes.json View 1 2 3 1 chunk +1 line, -0 lines 0 comments Download
A utils/apidoc/mdn/extract.dart View 1 2 3 1 chunk +1194 lines, -0 lines 0 comments Download
A utils/apidoc/mdn/extract.sh View 1 2 3 1 chunk +6 lines, -0 lines 0 comments Download
A utils/apidoc/mdn/extractRunner.js View 1 2 3 1 chunk +179 lines, -0 lines 0 comments Download
A utils/apidoc/mdn/full_run.sh View 1 2 3 1 chunk +8 lines, -0 lines 0 comments Download
A utils/apidoc/mdn/postProcess.dart View 1 2 3 1 chunk +468 lines, -0 lines 0 comments Download
A utils/apidoc/mdn/search.js View 1 2 3 1 chunk +58 lines, -0 lines 0 comments Download
A utils/apidoc/static/apidoc-styles.css View 1 2 3 1 chunk +88 lines, -0 lines 0 comments Download
A utils/apidoc/static/mdn-logo-tiny.png View 1 2 3 0 chunks +-1 lines, --1 lines 0 comments Download
M utils/dartdoc/client-live-nav.dart View 1 2 3 1 chunk +3 lines, -4 lines 0 comments Download
M utils/dartdoc/dartdoc.dart View 1 2 3 7 chunks +103 lines, -6 lines 0 comments Download
A utils/dartdoc/static/external-link.png View 1 2 3 0 chunks +-1 lines, --1 lines 0 comments Download
M utils/dartdoc/static/styles.css View 1 2 3 2 chunks +8 lines, -0 lines 0 comments Download

Messages

Total messages: 14 (0 generated)
Bob Nystrom
8 years, 11 months ago (2012-01-28 01:22:48 UTC) #1
Jacob
https://chromiumcodereview.appspot.com/9225039/diff/3003/utils/apidoc/apidoc.dart File utils/apidoc/apidoc.dart (right): https://chromiumcodereview.appspot.com/9225039/diff/3003/utils/apidoc/apidoc.dart#newcode24 utils/apidoc/apidoc.dart:24: print('Parsing MDN data...'); Seems like a low value message ...
8 years, 10 months ago (2012-01-30 21:36:21 UTC) #2
Bob Nystrom
Thanks! https://chromiumcodereview.appspot.com/9225039/diff/3003/utils/apidoc/apidoc.dart File utils/apidoc/apidoc.dart (right): https://chromiumcodereview.appspot.com/9225039/diff/3003/utils/apidoc/apidoc.dart#newcode24 utils/apidoc/apidoc.dart:24: print('Parsing MDN data...'); On 2012/01/30 21:36:21, Jacob wrote: ...
8 years, 10 months ago (2012-01-31 20:56:29 UTC) #3
Jacob
https://chromiumcodereview.appspot.com/9225039/diff/3003/utils/apidoc/apidoc.dart File utils/apidoc/apidoc.dart (right): https://chromiumcodereview.appspot.com/9225039/diff/3003/utils/apidoc/apidoc.dart#newcode40 utils/apidoc/apidoc.dart:40: final mdn; On 2012/01/31 20:56:29, Bob Nystrom wrote: > ...
8 years, 10 months ago (2012-01-31 21:08:19 UTC) #4
Bob Nystrom
Thanks! https://chromiumcodereview.appspot.com/9225039/diff/3003/utils/apidoc/apidoc.dart File utils/apidoc/apidoc.dart (right): https://chromiumcodereview.appspot.com/9225039/diff/3003/utils/apidoc/apidoc.dart#newcode40 utils/apidoc/apidoc.dart:40: final mdn; On 2012/01/31 21:08:19, Jacob wrote: > ...
8 years, 10 months ago (2012-01-31 21:26:37 UTC) #5
Jacob
lgtm
8 years, 10 months ago (2012-01-31 21:27:59 UTC) #6
Bob Nystrom
On 2012/01/31 21:27:59, Jacob wrote: > lgtm \o/
8 years, 10 months ago (2012-01-31 21:33:31 UTC) #7
nweiz
This code is... pretty hairy. Obviously this has been checked in already, and I think ...
8 years, 10 months ago (2012-02-01 00:10:39 UTC) #8
Jacob
I'll deal with the remaining postProcess comments tomorrow. https://chromiumcodereview.appspot.com/9225039/diff/3003/utils/apidoc/mdn/crawl.js File utils/apidoc/mdn/crawl.js (right): https://chromiumcodereview.appspot.com/9225039/diff/3003/utils/apidoc/mdn/crawl.js#newcode1 utils/apidoc/mdn/crawl.js:1: var ...
8 years, 10 months ago (2012-02-01 07:48:25 UTC) #9
Jacob
BTW, to clarify, Bob and I needed to collaborate on this code far before it ...
8 years, 10 months ago (2012-02-01 07:54:15 UTC) #10
nweiz
https://chromiumcodereview.appspot.com/9225039/diff/3003/utils/apidoc/mdn/crawl.js File utils/apidoc/mdn/crawl.js (right): https://chromiumcodereview.appspot.com/9225039/diff/3003/utils/apidoc/mdn/crawl.js#newcode1 utils/apidoc/mdn/crawl.js:1: var http = require('http'); On 2012/02/01 07:48:26, Jacob wrote: ...
8 years, 10 months ago (2012-02-01 21:23:02 UTC) #11
Jacob
Fixes are present in https://chromiumcodereview.appspot.com/9315026 https://chromiumcodereview.appspot.com/9225039/diff/3003/utils/apidoc/mdn/crawl.js File utils/apidoc/mdn/crawl.js (right): https://chromiumcodereview.appspot.com/9225039/diff/3003/utils/apidoc/mdn/crawl.js#newcode1 utils/apidoc/mdn/crawl.js:1: var http = require('http'); ...
8 years, 10 months ago (2012-02-02 05:26:38 UTC) #12
nweiz
https://chromiumcodereview.appspot.com/9225039/diff/3003/utils/apidoc/mdn/crawl.js File utils/apidoc/mdn/crawl.js (right): https://chromiumcodereview.appspot.com/9225039/diff/3003/utils/apidoc/mdn/crawl.js#newcode1 utils/apidoc/mdn/crawl.js:1: var http = require('http'); On 2012/02/02 05:26:38, Jacob wrote: ...
8 years, 10 months ago (2012-02-02 19:54:34 UTC) #13
Jacob
8 years, 10 months ago (2012-02-02 22:03:14 UTC) #14
https://chromiumcodereview.appspot.com/9225039/diff/3003/utils/apidoc/mdn/cra...
File utils/apidoc/mdn/crawl.js (right):

https://chromiumcodereview.appspot.com/9225039/diff/3003/utils/apidoc/mdn/cra...
utils/apidoc/mdn/crawl.js:1: var http = require('http');
On 2012/02/02 19:54:34, nweiz wrote:
> On 2012/02/02 05:26:38, Jacob wrote:
> > On 2012/02/01 21:23:02, nweiz wrote:
> > > On 2012/02/01 07:48:26, Jacob wrote:
> > > > On 2012/02/01 00:10:39, nweiz wrote:
> > > > > Why is this file in JS?
> > > > Because the dart server libraries currently lack the functionality we
> need. 
> > > > When they do this script should be ported.
> > > 
> > > It would be good to document exactly what's keeping all the JS scripts as
> JS.
> > 
> > that seems low value.  Just look at each call to a Node method (e.g. http.
and
> > fs.)
> > and you have something that is missing in Dart currently.  However I have
> added
> > a TODO to convert to dart when all these methods are available.
> 
> It was non-obvious to me. It's important that someone coming across this in
> three months is able to understand whether or not it should be converted to
> Dart.
The trouble is if I made a list of which methods still need to be implemented by
the dart server side support then that list will be obsolete in 3 months so
there isn't value in explicitly listing that here.

https://chromiumcodereview.appspot.com/9225039/diff/3003/utils/apidoc/mdn/ext...
File utils/apidoc/mdn/extract.dart (right):

https://chromiumcodereview.appspot.com/9225039/diff/3003/utils/apidoc/mdn/ext...
utils/apidoc/mdn/extract.dart:1: #import ("dart:html");
On 2012/02/01 21:23:02, nweiz wrote:
> On 2012/02/01 07:48:26, Jacob wrote:
> > On 2012/02/01 00:10:39, nweiz wrote:
> > > This whole file could use considerably more documentation. I had a very
> > > difficult time following it.
> > 
> > I agree that this script needs a larger comment describing the design but I
> > disagree that most of the small methods should have comments because they
are
> > mainly self explanatory.
> 
> Some of the methods are certainly self-explanatory, but some of them are less
so
> than they seem at first glance. For example, it would be useful to know what
> criteria determined the first line and why we needed to find it for
> "findFirstLine", it's not immediately obvious what all the parameters for
> "findBest" mean, etc.

Done.

https://chromiumcodereview.appspot.com/9225039/diff/3003/utils/apidoc/mdn/ext...
utils/apidoc/mdn/extract.dart:344:
window.postMessage("START_DART_MESSAGE_UNIQUE_IDENTIFIER$dbJson", "*");
On 2012/02/02 19:54:34, nweiz wrote:
> On 2012/02/02 05:26:38, Jacob wrote:
> > On 2012/02/01 21:23:02, nweiz wrote:
> > > On 2012/02/01 07:48:26, Jacob wrote:
> > > > On 2012/02/01 00:10:39, nweiz wrote:
> > > > > I'm pretty confused about why this is happening. I may figure it out
as
> I
> > > read
> > > > > more of the CL, but it would be nice to have some documentation here
> > > > explaining
> > > > > it.
> > > > See the comment above... this is a hack to work around a bad bug in the
> JSON
> > > > parser.
> > > 
> > > The comment made me think that only the "\n" stuff was a JSON bug. How
does
> > > postMessage fit in to that?
> > 
> > postMessage is just a natural way you communicate from Dart to JS.  
> 
> What does that have to do with JSON parser bugs?
The postMessage line isn't related to the JSON bug. Added a comment to clarify
its use.
  // Use postMessage to end the JSON to JavaScript. TODO(jacobr): use a simple
  // isolate based Dart-JS interop solution in the future.

https://chromiumcodereview.appspot.com/9225039/diff/3003/utils/apidoc/mdn/pos...
File utils/apidoc/mdn/postProcess.dart (right):

https://chromiumcodereview.appspot.com/9225039/diff/3003/utils/apidoc/mdn/pos...
utils/apidoc/mdn/postProcess.dart:23: List<String>
sortStringCollection(Collection<String> collection) {
On 2012/02/02 19:54:34, nweiz wrote:
> On 2012/02/02 05:26:38, Jacob wrote:
> > On 2012/02/01 00:10:39, nweiz wrote:
> > > I'd call this sortCollection and type it as "Collection<Comparable> ->
> > > List<Comparable>". Seems like methods should accept as broad a type as
> > possible,
> > > and the caller should cast to something more specific.
> > 
> > There is little value in being generic when I only need to sort strings. 
This
> > is a helper method in a pretty printer not a generic library call.
> 
> There's little value in being String-specific, either. I think making the
method
> broader when there's no cost to doing so is a good idea, even if you don't
> anticipate re-using it. It expresses the intent of the method better, which
> makes the code easier to understand. When the method is called
> "sortStringCollection", I expect it to do something String-specific and have
to
> spend extra mental cycles figuring out that it doesn't.

having a sortCollection method would be reasonable. However keep in mind that in
Dart that would mean the output would need to be a 
List<Collection> instead of a List<String> which is a little annoying.
Anyway, if you feel really strongly about this I could go either way.
FWIW, this method could easily become string specific if we decided it was
important to use a case insensitive string comparison method, etc.
Anyway, as a design principle I believe that it is rarely worth it to generalize
code before you have to. If needed it would be trivial to refactor this to a
general method in the future.  Being more specific makes code less abstract so
often easier to follow.  Obviously in this case the code is very simple so it
isn't a big deal one way or the other.

https://chromiumcodereview.appspot.com/9225039/diff/3003/utils/apidoc/mdn/pos...
utils/apidoc/mdn/postProcess.dart:52: sb.add("""
On 2012/02/02 19:54:34, nweiz wrote:
> On 2012/02/02 05:26:38, Jacob wrote:
> > On 2012/02/01 00:10:39, nweiz wrote:
> > > Style nit: incorrect indentation.
> > this is the correct indentation so that the output HTML is nicely indented.
> 
> "<tr>" and "</tr>" should have the same indentation.

fixed

https://chromiumcodereview.appspot.com/9225039/diff/3003/utils/apidoc/mdn/pos...
utils/apidoc/mdn/postProcess.dart:81: score++;
On 2012/02/01 00:10:39, nweiz wrote:
> Why would we ever want to choose a skipped entry?
I doubt we would. Added a TODO to consider removing skipped entries completely
instead of just giving them lower scores.

https://chromiumcodereview.appspot.com/9225039/diff/3003/utils/apidoc/mdn/pos...
utils/apidoc/mdn/postProcess.dart:103: num score = scoreEntry(entry, type);
On 2012/02/02 19:54:34, nweiz wrote:
> On 2012/02/02 05:26:38, Jacob wrote:
> > On 2012/02/01 00:10:39, nweiz wrote:
> > > Indentation.
> > > 
> > > Alternately, "if (entry == null) continue" on the previous line.
> > control flow with continue is less readable in general.
> 
> It seems to me like it's the same case as "if (...) return". I find it more
> readable than deeply-nested conditionals.

Some people go so far as to prohibit 
if (...) return; calls at the top of methods
I think those are fine and can improve readability in a lot of cases.
However, returns in arbitrary locations in the middle of methods are bad and
significantly hurt readability by making the code flow more surprising.
As code is written once and often read multiple times I prefer less surprising
code to more terse code for cases when the extra code bloat is small.

https://chromiumcodereview.appspot.com/9225039/diff/3003/utils/apidoc/mdn/pos...
utils/apidoc/mdn/postProcess.dart:132: final sb = new StringBuffer();
On 2012/02/02 19:54:34, nweiz wrote:
> On 2012/02/02 05:26:38, Jacob wrote:
> > On 2012/02/01 00:10:39, nweiz wrote:
> > > The vast number of string buffers being used in this method make my head
> spin.
> > > In lieu of an actual template system, I think it would be cleaner to write
> > this
> > > code as though one existed. That is, have an individual method for each
file
> > > that will be created; put all string buffer management into those methods.
> > Then
> > > main's responsibility becomes simply packaging the data up into the
> structures
> > > that each of these faux-template methods needs.
> > I agree that this code is ugly due to the lack of a template system.  Added
a
> > TODO.  However, it isn't worthwhile to cleanup the style for this debug
output
> > generation code here as it is throw away debugging code.  The only
worthwhile
> > code that needs to be maintainable in this file is the post processing code.

> As
> > mentioned in the TODO at the top of the file I should split that out from
this
> > debugging code.  The post processing code should be maintainable, the
> debugging
> > output code should be just quick and dirty and so no extra work should be
> > performed to make it production quality.
> 
> When will the debugging code be removed?

in my copious free time.  If you think it is a priority you are welcome to split
out the actual logic from the code that generates debugging html.

Powered by Google App Engine
This is Rietveld 408576698