1
0
Fork 0
mirror of https://github.com/jashkenas/coffeescript.git synced 2022-11-09 12:23:24 -05:00
jashkenas--coffeescript/documentation/v2/sidebar.html
Geoffrey Booth 6d21dc5495 [CS2] Comments (#4572)
* Make `addLocationDataFn` more DRY

* Style fixes

* Provide access to full parser inside our custom function running in parser.js; rename the function to lay the groundwork for adding data aside from location data

* Fix style.

* Fix style.

* Label test comments

* Update grammar to remove comment tokens; update DSL to call new helper function that preserves comments through parsing

* New implementation of compiling block comments: the lexer pulls them out of the token stream, attaching them as a property to a token; the rewriter moves the attachment around so it lives on a token that is destined to make it through to compilation (and in a good placement); and the nodes render the block comment. All tests but one pass (commented out).

* If a comment follows a class declaration, move the comment inside the class body

* Style

* Improve indentation of multiline comments

* Fix indentation for block comments, at least in the cases covered by the one failing test

* Don’t reverse the order of unshifted comments

* Simplify rewriter’s handling of comments, generalizing the special case

* Expand the list of tokens we need to avoid for passing comments through the parser; get some literal tokens to have nodes created for them so that the comments pass through

* Improve comments; fix multiline flag

* Prepare HereComments for processing line comments

* Line comments, first draft: the tests pass, but the line comments aren’t indented and sometimes trail previous lines when they shouldn’t; updated compiler output in following commit

* Updated compiler, now with line comments

* `process` doesn’t exist in the browser, so we should check for its existence first

* Update parser output

* Test that proves #4290 is fixed

* Indent line comments, first pass

* Compiled output with indented line comments

* Comments that start a new line shouldn’t trail; don’t skip comments attached to generated tokens; stop looking for indentation once we hit a newline

* Revised output

* Cleanup

* Split “multiline” line comment tokens, shifting them forward or back as appropriate

* Fix comments in module specifiers

* Abstract attaching comments to a node

* Line comments in interpolated strings

* Line comments can’t be multiline anymore

* Improve handling of blank lines and indentation of following comments that start a new line (i.e. don’t trail)

* Make comments compilation more object-oriented

* Remove lots of dead code that we don’t need anymore because a comment is never a node, only a fragment

* Improve eqJS helper

* Fix #4290 definitively, with improved output for arrays with interspersed block comments

* Add support for line comments output interspersed within arrays

* Fix mistake, don’t lose the variable we’re working on

* Remove redundant replacements

* Check for indentation only from the start of the string

* Indentations in generated JS are always multiples of two spaces (never tabs) so just look for 2+ spaces

* Update package versions; run Babel twice, once for each preset, temporarily until a Babili bug is fixed that prevents it from running with the env preset

* Don’t rely on `fragment.type`, which can break when the compiler is minified

* Updated generated docs and browser compiler

* Output block comments after function arguments

* Comments appear above scope `var` declarations; better tracking of generated `JS` tokens created only to shepherd comments through to the output

* Create new FuncGlyph node, to hold comments we want to output near the function parameters

* Block comments between `)` and `->`/`=>` get output between `)` and `{`.

* Fix indentation of comments that are the first line inside a bare mode block

* Updated output

* Full Flow example

* Updated browser compiler

* Abstract and organize comment fragment generation code; store more properties on the comment fragment objects; make `throw` behave like `return`

* Abstract token insertion code

* Add missing locationData to STRING_START token, giving it the locationData of the overall StringWithInterpolations token so that comments attached to STRING_START end up on the StringWithInterpolations node

* Allow `SUPER` tokens to carry comments

* Rescue comments from `Existence` nodes and `If` nodes’ conditions

* Rescue comments after `\` line continuation tokens

* Updated compiled output

* Updated browser compiler

* Output block comments in the same `compileFragments` method as line comments, except for inline block comments

* Comments before splice

* Updated browser compiler

* Track compiledComments as a property of Base, to ensure that it’s not a global variable

* Docs: split up the Usage section

* Docs for type annotations via Flow; updated docs output

* Update regular comments documentation

* Updated browser compiler

* Comments before soak

* Comments before static methods, and probably before `@variable =` (this) assignments generally

* Comments before ‘if exists?’, refactor comment before ‘if this.var’ to be more precise, improve helper methods

* Comments before a method that contains ‘super()’ should output above the method property, not above the ‘super.method()’ call

* Fix missing comments before `if not` (i.e. before a UNARY token)

* Fix comments before ‘for’; add test for comment before assignment if (fixed in earlier commit)

* Comments within heregexes

* Updated browser compiler

* Update description to reflect what’s now happening in compileCommentFragments

* Preserve blank lines between line comments; output “whitespace-only” line comments as blank lines, rather than `//` following by whitespace

* Better future-proof comments tests

* Comments before object destructuring; abstract method for setting comments aside before compilation

* Handle more cases of comments before or after `for` loop declaration lines

* Fix indentation of comments preceding `for` loops

* Fix comment before splat function parameter

* Catch another RegexWithInterpolations comment edge case

* Updated browser compiler

* Change heregex example to one that’s more readable; update output

* Remove a few last references to the defunct HERECOMMENT token

* Abstract location hash creation into a function

* Improved clarity per code review notes

* Updated browser compiler
2017-08-02 19:34:34 -07:00

200 lines
9.1 KiB
HTML

<nav class="contents" id="contents">
<ul class="nav">
<li class="nav-item">
<a href="#top" class="nav-link" data-action="sidebar-nav">Overview</a>
</li>
<li class="nav-item">
<a href="#coffeescript-2" class="nav-link" data-action="sidebar-nav">CoffeeScript 2</a>
</li>
<li class="nav-item">
<a href="#installation" class="nav-link" data-action="sidebar-nav">Installation</a>
</li>
<li class="nav-item">
<a href="#usage" class="nav-link" data-action="sidebar-nav">Usage</a>
<ul class="nav">
<li class="nav-item">
<a href="#cli" class="nav-link" data-action="sidebar-nav">Command Line</a>
</li>
<li class="nav-item">
<a href="#es2015plus-output" class="nav-link" data-action="sidebar-nav">ES2015+ Output</a>
</li>
<li class="nav-item">
<a href="#nodejs-usage" class="nav-link" data-action="sidebar-nav">Node.js</a>
</li>
</ul>
</li>
<li class="nav-item">
<a href="#language" class="nav-link" data-action="sidebar-nav">Language Reference</a>
<ul class="nav">
<li class="nav-item">
<a href="#functions" class="nav-link" data-action="sidebar-nav">Functions</a>
</li>
<li class="nav-item">
<a href="#strings" class="nav-link" data-action="sidebar-nav">Strings</a>
</li>
<li class="nav-item">
<a href="#objects-and-arrays" class="nav-link" data-action="sidebar-nav">Objects and Arrays</a>
</li>
<li class="nav-item">
<a href="#comments" class="nav-link" data-action="sidebar-nav">Comments</a>
</li>
<li class="nav-item">
<a href="#lexical-scope" class="nav-link" data-action="sidebar-nav">Lexical Scoping and Variable Safety</a>
</li>
<li class="nav-item">
<a href="#conditionals" class="nav-link" data-action="sidebar-nav">If, Else, Unless, and Conditional Assignment</a>
</li>
<li class="nav-item">
<a href="#splats" class="nav-link" data-action="sidebar-nav">Splats, or Rest Parameters/Spread Syntax</a>
</li>
<li class="nav-item">
<a href="#loops" class="nav-link" data-action="sidebar-nav">Loops and Comprehensions</a>
</li>
<li class="nav-item">
<a href="#slices" class="nav-link" data-action="sidebar-nav">Array Slicing and Splicing</a>
</li>
<li class="nav-item">
<a href="#expressions" class="nav-link" data-action="sidebar-nav">Everything is an Expression</a>
</li>
<li class="nav-item">
<a href="#operators" class="nav-link" data-action="sidebar-nav">Operators and Aliases</a>
</li>
<li class="nav-item">
<a href="#existential-operator" class="nav-link" data-action="sidebar-nav">Existential Operator</a>
</li>
<li class="nav-item">
<a href="#destructuring" class="nav-link" data-action="sidebar-nav">Destructuring Assignment</a>
</li>
<li class="nav-item">
<a href="#chaining" class="nav-link" data-action="sidebar-nav">Chaining Function Calls</a>
</li>
<li class="nav-item">
<a href="#fat-arrow" class="nav-link" data-action="sidebar-nav">Bound (Fat Arrow) Functions</a>
</li>
<li class="nav-item">
<a href="#generators" class="nav-link" data-action="sidebar-nav">Generator Functions</a>
</li>
<li class="nav-item">
<a href="#async-functions" class="nav-link" data-action="sidebar-nav">Async Functions</a>
</li>
<li class="nav-item">
<a href="#classes" class="nav-link" data-action="sidebar-nav">Classes</a>
</li>
<li class="nav-item">
<a href="#prototypal-inheritance" class="nav-link" data-action="sidebar-nav">Prototypal Inheritance</a>
</li>
<li class="nav-item">
<a href="#switch" class="nav-link" data-action="sidebar-nav">Switch and Try/Catch</a>
</li>
<li class="nav-item">
<a href="#comparisons" class="nav-link" data-action="sidebar-nav">Chained Comparisons</a>
</li>
<li class="nav-item">
<a href="#regexes" class="nav-link" data-action="sidebar-nav">Block Regular Expressions</a>
</li>
<li class="nav-item">
<a href="#tagged-template-literals" class="nav-link" data-action="sidebar-nav">Tagged Template Literals</a>
</li>
<li class="nav-item">
<a href="#modules" class="nav-link" data-action="sidebar-nav">Modules</a>
</li>
<li class="nav-item">
<a href="#embedded" class="nav-link" data-action="sidebar-nav">Embedded JavaScript</a>
</li>
<li class="nav-item">
<a href="#jsx" class="nav-link" data-action="sidebar-nav">JSX</a>
</li>
</ul>
</li>
<li class="nav-item">
<a href="#type-annotations" class="nav-link" data-action="sidebar-nav">Type Annotations</a>
</li>
<li class="nav-item">
<a href="#literate" class="nav-link" data-action="sidebar-nav">Literate CoffeeScript</a>
</li>
<li class="nav-item">
<a href="#source-maps" class="nav-link" data-action="sidebar-nav">Source Maps</a>
</li>
<li class="nav-item">
<a href="#cake" class="nav-link" data-action="sidebar-nav">Cake, and Cakefiles</a>
</li>
<li class="nav-item">
<a href="#scripts" class="nav-link" data-action="sidebar-nav"><code>"text/coffeescript"</code> Script Tags</a>
</li>
<li class="nav-item">
<a href="test.html" class="nav-link" data-action="sidebar-nav">Browser-Based Tests</a>
</li>
<li class="nav-item">
<a href="#resources" class="nav-link" data-action="sidebar-nav">Resources</a>
<ul class="nav">
<li class="nav-item">
<a href="#books" class="nav-link" data-action="sidebar-nav">Books</a>
</li>
<li class="nav-item">
<a href="#screencasts" class="nav-link" data-action="sidebar-nav">Screencasts</a>
</li>
<li class="nav-item">
<a href="#examples" class="nav-link" data-action="sidebar-nav">Examples</a>
</li>
<li class="nav-item">
<a href="#chat" class="nav-link" data-action="sidebar-nav">Chat</a>
</li>
<li class="nav-item">
<a href="#annotated-source" class="nav-link" data-action="sidebar-nav">Annotated Source</a>
</li>
<li class="nav-item">
<a href="#contributing" class="nav-link" data-action="sidebar-nav">Contributing</a>
</li>
</ul>
</li>
<li class="nav-item">
<a href="#unsupported" class="nav-link" data-action="sidebar-nav">Unsupported ECMAScript Features</a>
<ul class="nav">
<li class="nav-item">
<a href="#unsupported-let-const" class="nav-link" data-action="sidebar-nav"><code>let</code> and <code>const</code></a>
</li>
<li class="nav-item">
<a href="#unsupported-named-functions" class="nav-link" data-action="sidebar-nav">Named Functions and Function Declarations</a>
</li>
<li class="nav-item">
<a href="#unsupported-get-set" class="nav-link" data-action="sidebar-nav"><code>get</code> and <code>set</code> Shorthand Syntax</a>
</li>
</ul>
</li>
<li class="nav-item">
<a href="#breaking-changes" class="nav-link" data-action="sidebar-nav">Breaking Changes From 1.x</a>
<ul class="nav">
<li class="nav-item">
<a href="#breaking-change-fat-arrow" class="nav-link" data-action="sidebar-nav">Bound (Fat Arrow) Functions</a>
</li>
<li class="nav-item">
<a href="#breaking-changes-default-values" class="nav-link" data-action="sidebar-nav">Default Values</a>
</li>
<li class="nav-item">
<a href="#breaking-changes-bound-generator-functions" class="nav-link" data-action="sidebar-nav">Bound Generator Functions</a>
</li>
<li class="nav-item">
<a href="#breaking-changes-classes" class="nav-link" data-action="sidebar-nav">Classes</a>
</li>
<li class="nav-item">
<a href="#breaking-changes-super-extends" class="nav-link" data-action="sidebar-nav"><code>super</code> and <code>extends</code></a>
</li>
<li class="nav-item">
<a href="#breaking-changes-jsx-and-the-less-than-and-greater-than-operators" class="nav-link" data-action="sidebar-nav">JSX and the <code>&lt;</code> and <code>&gt;</code> Operators</a>
</li>
<li class="nav-item">
<a href="#breaking-changes-literate-coffeescript" class="nav-link" data-action="sidebar-nav">Literate CoffeeScript Parsing</a>
</li>
<li class="nav-item">
<a href="#breaking-changes-argument-parsing-and-shebang-lines" class="nav-link" data-action="sidebar-nav">Argument Parsing and <code>#!</code> Lines</a>
</li>
</ul>
</li>
<li class="nav-item">
<a href="#changelog" class="nav-link" data-action="sidebar-nav">Changelog</a>
</li>
<li class="nav-item">
<a href="/v1/" class="nav-link" data-action="sidebar-nav">Version 1.x Documentation</a>
</li>
</ul>
</nav>