Adding documentation to charset_range.js
This commit is contained in:
		
							parent
							
								
									7ca4b95cd7
								
							
						
					
					
						commit
						d8a635fa8f
					
				@ -1,9 +1,13 @@
 | 
				
			|||||||
 | 
					// CharsetRange nodes are used for `[a-z]` regular expression syntax. The two
 | 
				
			||||||
 | 
					// literal or escape nodes are rendered with a hyphen between them.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import util from '../../util.js';
 | 
					import util from '../../util.js';
 | 
				
			||||||
import _ from 'lodash';
 | 
					import _ from 'lodash';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export default {
 | 
					export default {
 | 
				
			||||||
  type: 'charset-range',
 | 
					  type: 'charset-range',
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  // Renders the charset range into the currently set container
 | 
				
			||||||
  _render() {
 | 
					  _render() {
 | 
				
			||||||
    var contents = [
 | 
					    var contents = [
 | 
				
			||||||
      this.first,
 | 
					      this.first,
 | 
				
			||||||
@ -11,11 +15,13 @@ export default {
 | 
				
			|||||||
      this.last
 | 
					      this.last
 | 
				
			||||||
    ];
 | 
					    ];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Render the nodes of the range.
 | 
				
			||||||
    return Promise.all([
 | 
					    return Promise.all([
 | 
				
			||||||
      this.first.render(this.container.group()),
 | 
					      this.first.render(this.container.group()),
 | 
				
			||||||
      this.last.render(this.container.group())
 | 
					      this.last.render(this.container.group())
 | 
				
			||||||
    ])
 | 
					    ])
 | 
				
			||||||
      .then(() => {
 | 
					      .then(() => {
 | 
				
			||||||
 | 
					        // Space the nodes and hyphen horizontally.
 | 
				
			||||||
        util.spaceHorizontally(contents, {
 | 
					        util.spaceHorizontally(contents, {
 | 
				
			||||||
          padding: 5
 | 
					          padding: 5
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
@ -23,9 +29,12 @@ export default {
 | 
				
			|||||||
  },
 | 
					  },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  setup() {
 | 
					  setup() {
 | 
				
			||||||
 | 
					    // The two nodes for the range. In `[a-z]` these would be
 | 
				
			||||||
 | 
					    // [Literal](./literal.html) nodes for "a" and "z".
 | 
				
			||||||
    this.first = this.properties.first;
 | 
					    this.first = this.properties.first;
 | 
				
			||||||
    this.last = this.properties.last;
 | 
					    this.last = this.properties.last;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Report invalid expression when extents of the range are out of order.
 | 
				
			||||||
    if (this.first.ordinal > this.last.ordinal) {
 | 
					    if (this.first.ordinal > this.last.ordinal) {
 | 
				
			||||||
      throw `Range out of order in character class: ${this.textValue}`;
 | 
					      throw `Range out of order in character class: ${this.textValue}`;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user