Skip to content

Commit

Permalink
Fix syntax highlighting in some documentation examples (#2050)
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewJakubowicz committed Aug 16, 2021
1 parent e6dc6a7 commit 8758e06
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 33 deletions.
2 changes: 1 addition & 1 deletion packages/lit-html/src/directives/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class CacheDirective extends Directive {
*
* Example:
*
* ```
* ```js
* let checked = false;
*
* html`
Expand Down
2 changes: 2 additions & 0 deletions packages/lit-html/src/directives/live.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ class LiveDirective extends Directive {
* it alone. If this is not what you want--if you want to overwrite the DOM
* value with the bound value no matter what--use the `live()` directive:
*
* ```js
* html`<input .value=${live(x)}>`
* ```
*
* `live()` performs a strict equality check agains the live DOM value, and if
* the new value is equal to the live value, does nothing. This means that
Expand Down
17 changes: 9 additions & 8 deletions packages/lit-html/src/directives/ref.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,16 @@ class RefDirective extends AsyncDirective {
* followed by another call with the new element it was rendered to (if any).
*
* @example
* ```js
* // Using Ref object
* const inputRef = createRef();
* render(html`<input ${ref(inputRef)}>`, container);
* inputRef.value.focus();
*
* // Using Ref object
* const inputRef = createRef();
* render(html`<input ${ref(inputRef)}>`, container);
* inputRef.value.focus();
*
* // Using callback
* const callback = (inputElement) => inputElement.focus();
* render(html`<input ${ref(callback)}>`, container);
* // Using callback
* const callback = (inputElement) => inputElement.focus();
* render(html`<input ${ref(callback)}>`, container);
* ```
*/
export const ref = directive(RefDirective);

Expand Down
6 changes: 4 additions & 2 deletions packages/lit-html/src/directives/until.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,10 @@ class UntilDirective extends AsyncDirective {
*
* Example:
*
* const content = fetch('./content.txt').then(r => r.text());
* html`${until(content, html`<span>Loading...</span>`)}`
* ```js
* const content = fetch('./content.txt').then(r => r.text());
* html`${until(content, html`<span>Loading...</span>`)}`
* ```
*/
export const until = directive(UntilDirective);

Expand Down
2 changes: 1 addition & 1 deletion packages/reactive-element/src/decorators/custom-element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const standardCustomElement = (
/**
* Class decorator factory that defines the decorated class as a custom element.
*
* ```
* ```js
* @customElement('my-element')
* class MyElement extends LitElement {
* render() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const legacyMatches =
* @param selector A string which filters the results to elements that match
* the given css selector.
*
* * @example
* @example
* ```ts
* class MyElement {
* @queryAssignedNodes('list', true, '.item')
Expand Down
46 changes: 26 additions & 20 deletions packages/reactive-element/src/reactive-element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -449,10 +449,12 @@ export abstract class ReactiveElement
* `getPropertyDescriptor`. To customize the options for a property,
* implement `createProperty` like this:
*
* ```ts
* static createProperty(name, options) {
* options = Object.assign(options, {myOption: true});
* super.createProperty(name, options);
* }
* ```
*
* @nocollapse
* @category properties
Expand Down Expand Up @@ -490,22 +492,24 @@ export abstract class ReactiveElement
* If no descriptor is returned, the property will not become an accessor.
* For example,
*
* class MyElement extends LitElement {
* static getPropertyDescriptor(name, key, options) {
* const defaultDescriptor =
* super.getPropertyDescriptor(name, key, options);
* const setter = defaultDescriptor.set;
* return {
* get: defaultDescriptor.get,
* set(value) {
* setter.call(this, value);
* // custom action.
* },
* configurable: true,
* enumerable: true
* }
* ```ts
* class MyElement extends LitElement {
* static getPropertyDescriptor(name, key, options) {
* const defaultDescriptor =
* super.getPropertyDescriptor(name, key, options);
* const setter = defaultDescriptor.set;
* return {
* get: defaultDescriptor.get,
* set(value) {
* setter.call(this, value);
* // custom action.
* },
* configurable: true,
* enumerable: true
* }
* }
* }
* ```
*
* @nocollapse
* @category properties
Expand Down Expand Up @@ -1038,7 +1042,7 @@ export abstract class ReactiveElement
*
* For instance, to schedule updates to occur just before the next frame:
*
* ```
* ```js
* protected async performUpdate(): Promise<unknown> {
* await new Promise((resolve) => requestAnimationFrame(() => resolve()));
* super.performUpdate();
Expand Down Expand Up @@ -1177,12 +1181,14 @@ export abstract class ReactiveElement
* language is ES5 (https://github.com/microsoft/TypeScript/issues/338).
* This method should be overridden instead. For example:
*
* class MyElement extends LitElement {
* async getUpdateComplete() {
* await super.getUpdateComplete();
* await this._myChild.updateComplete;
* }
* ```js
* class MyElement extends LitElement {
* async getUpdateComplete() {
* await super.getUpdateComplete();
* await this._myChild.updateComplete;
* }
* }
* ```
* @category updates
*/
protected getUpdateComplete(): Promise<boolean> {
Expand Down

0 comments on commit 8758e06

Please sign in to comment.