How-To files generated with markdown spippet injector

This commit is contained in:
Nikolay Iliev
2016-04-15 14:49:44 +03:00
parent ee292f771f
commit cdeba37c72
10 changed files with 204 additions and 154 deletions

View File

@ -5,23 +5,9 @@ import colorModule = require("color");
import layoutHelper = require("./layout-helper"); import layoutHelper = require("./layout-helper");
import commonTests = require("./common-layout-tests"); import commonTests = require("./common-layout-tests");
// <snippet module="ui/layouts/absolute-layout" title="absolute-layout"> // >> absolute-layout-require
// # AbsoluteLayout
// Using a AbsoluteLayout requires the AbsoluteLayout module.
// ``` JavaScript
import absoluteLayoutModule = require("ui/layouts/absolute-layout"); import absoluteLayoutModule = require("ui/layouts/absolute-layout");
// ``` // << absolute-layout-require
// </snippet>
// ### Declaring a AbsoluteLayout.
//``` XML
// <Page>
// <AbsoluteLayout>
// <Label text="This is Label 1" left="30" top="70" />
// </AbsoluteLayout>
// </Page>
//```
// </snippet>
export class AbsoluteLayoutTest extends testModule.UITest<absoluteLayoutModule.AbsoluteLayout> { export class AbsoluteLayoutTest extends testModule.UITest<absoluteLayoutModule.AbsoluteLayout> {
@ -31,9 +17,7 @@ export class AbsoluteLayoutTest extends testModule.UITest<absoluteLayoutModule.A
public snippet() { public snippet() {
// <snippet module="ui/layouts/absolute-layout" title="absolute-layout"> // >> absolute-layout-populating
// ## Creating and populating a AbsoluteLayout with children
// ``` JavaScript
var absoluteLayout = new absoluteLayoutModule.AbsoluteLayout(); var absoluteLayout = new absoluteLayoutModule.AbsoluteLayout();
absoluteLayout.width = 230; absoluteLayout.width = 230;
absoluteLayout.height = 230; absoluteLayout.height = 230;
@ -48,8 +32,7 @@ export class AbsoluteLayoutTest extends testModule.UITest<absoluteLayoutModule.A
label.id = "LT"; label.id = "LT";
label.style.backgroundColor = new colorModule.Color("Red"); label.style.backgroundColor = new colorModule.Color("Red");
absoluteLayout.addChild(label); absoluteLayout.addChild(label);
// ``` // << absolute-layout-populating
// </snippet>
} }
public testAll() { public testAll() {

View File

@ -0,0 +1,19 @@
---
nav-title: "absolute-layout How-To"
title: "How-To"
description: "Examples for using absolute-layout"
---
# AbsoluteLayout
Using a AbsoluteLayout requires the AbsoluteLayout module.
<snippet id='absolute-layout-require'/>
``` XML
<Page>
<AbsoluteLayout>
<Label text="This is Label 1" left="30" top="70" />
</AbsoluteLayout>
</Page>
```
## Creating and populating a AbsoluteLayout with children
<snippet id='absolute-layout-populating'/>

View File

@ -6,32 +6,13 @@ import testModule = require("../ui-test");
import layoutHelper = require("./layout-helper"); import layoutHelper = require("./layout-helper");
import commonTests = require("./common-layout-tests"); import commonTests = require("./common-layout-tests");
// <snippet module="ui/layouts/dock-layout" title="dock-layout"> // >> <snippet id='dock-layout-require'/>
// # DockLayout
// Using a DockLayout requires the DockLayout module.
// ``` JavaScript
import dockModule = require("ui/layouts/dock-layout"); import dockModule = require("ui/layouts/dock-layout");
// ``` // << <snippet id='dock-layout-require'/>
// ### Declaring a DockLayout. // >> dock-layout-others
//``` XML
//<Page>
// <DockLayout stretchLastChild="true" >
// <Button dock="left" text="left" style="background-color: red; margin: 5;"/ >/ >
// <Button dock="top" text="top" style="background-color: lightblue; margin: 5;"/ >
// <Button dock="right" text="right" style="background-color: lightgreen; margin: 5;"/ >
// <Button dock="bottom" text="bottom" style="background-color: lightpink; margin: 5;"/ >
// <Button text="fill" style="background-color: wheat; margin: 5;"/ >
// </DockLayout >
//</Page>
//```
// </snippet>
// Other frequently used modules when working with a DockLayout include:
// ``` JavaScript
import enums = require("ui/enums"); import enums = require("ui/enums");
// ``` // << dock-layout-others
// </snippet>
export class DockLayoutTest extends testModule.UITest<DockLayout> { export class DockLayoutTest extends testModule.UITest<DockLayout> {
@ -164,30 +145,24 @@ export class DockLayoutTest extends testModule.UITest<DockLayout> {
} }
public test_codesnippets() { public test_codesnippets() {
// <snippet module="ui/layouts/dock-layout" title="dock-layout"> // >> dock-layout-create
// ## Create DockLayout
// ``` JavaScript
var dockLayout = new dockModule.DockLayout(); var dockLayout = new dockModule.DockLayout();
// ``` // << dock-layout-create
// ## Add child view to layout // >> dock-layout-addchild
// ``` JavaScript
var btn = new button.Button(); var btn = new button.Button();
dockLayout.addChild(btn); dockLayout.addChild(btn);
// ``` // << dock-layout-addchild
// ## Remove child view from layout // >> dock-layout-removechild
// ``` JavaScript
dockLayout.removeChild(btn); dockLayout.removeChild(btn);
// ``` // << dock-layout-removechild
// ## Setting the dock property // >> dock-layout-setdocl
// ``` JavaScript
var btnDockedToRight = new button.Button(); var btnDockedToRight = new button.Button();
dockModule.DockLayout.setDock(btnDockedToRight, enums.Dock.right); dockModule.DockLayout.setDock(btnDockedToRight, enums.Dock.right);
dockLayout.addChild(btnDockedToRight); dockLayout.addChild(btnDockedToRight);
// ``` // << dock-layout-setdocl
// </snippet>
} }
public test_percent_support() { public test_percent_support() {

View File

@ -0,0 +1,37 @@
---
nav-title: "dock-layout How-To"
title: "How-To"
description: "Examples for using dock-layout"
---
# DockLayout
Using a DockLayout requires the DockLayout module.
<snippet id='dock-layout-require'/>
### Declaring a DockLayout.
``` XML
<Page>
<DockLayout stretchLastChild="true">
<Button dock="left" text="left" style="background-color: red; margin: 5;" />
<Button dock="top" text="top" style="background-color: lightblue; margin: 5;" />
<Button dock="right" text="right" style="background-color: lightgreen; margin: 5;" />
<Button dock="bottom" text="bottom" style="background-color: lightpink; margin: 5;" />
<Button text="fill" style="background-color: wheat; margin: 5;" />
</DockLayout>
</Page>
```
Other frequently used modules when working with a DockLayout include:
<snippet id='dock-layout-others'/>
## Create DockLayout
<snippet id='dock-layout-create'/>
## Add child view to layout
<snippet id='dock-layout-addchild'/>
## Remove child view from layout
<snippet id='dock-layout-removechild'/>
## Setting the dock property
<snippet id='dock-layout-setdocl'/>

View File

@ -561,27 +561,12 @@ export class GridLayoutTest extends testModule.UITest<GridLayout> {
} }
public test_codesnippets = function () { public test_codesnippets = function () {
// <snippet module="ui/layouts/grid-layout" title="grid-layout"> // >> grid-layout-require
// ## GridLayout sample
// ### Creating Grid Layout via code.
// ``` JavaScript
//var layout = require("ui/layouts/grid-layout"); //var layout = require("ui/layouts/grid-layout");
var gridLayout = new GridLayout(); var gridLayout = new GridLayout();
// ``` // << grid-layout-require
// ### Create grid layout with an xml declaration // >> grid-layout-addviews
// ``` XML
// <GridLayout columns="80, *, auto" rows="auto, *" >
// <Button col="0" />
// <Button col="1" />
// <Button col="2" />
//// by default column and row are set to 0
// <Button row="1" colSpan="3" />
// </GridLayout>
// ```
// ### Add views to grid layout
// ``` JavaScript
var btn1 = new Button(); var btn1 = new Button();
var btn2 = new Button(); var btn2 = new Button();
var btn3 = new Button(); var btn3 = new Button();
@ -590,27 +575,23 @@ export class GridLayoutTest extends testModule.UITest<GridLayout> {
gridLayout.addChild(btn2); gridLayout.addChild(btn2);
gridLayout.addChild(btn3); gridLayout.addChild(btn3);
gridLayout.addChild(btn4); gridLayout.addChild(btn4);
// ``` // << grid-layout-addviews
// ### Set column property on views - btn1 in first column, btn2 is second and btn3 in third // >> grid-layout-setcolumn
// ``` JavaScript
GridLayout.setColumn(btn1, 0); GridLayout.setColumn(btn1, 0);
GridLayout.setColumn(btn2, 1); GridLayout.setColumn(btn2, 1);
GridLayout.setColumn(btn3, 2); GridLayout.setColumn(btn3, 2);
// ``` // << grid-layout-setcolumn
// ### Set row property on btn4. // >> grid-layout-setrow
// ``` JavaScript
GridLayout.setRow(btn4, 1); GridLayout.setRow(btn4, 1);
// ``` // << grid-layout-setrow
// ### Set columnSpan property on btn4 to stretch into all columns // >> grid-layout-columnspan
// ``` JavaScript
GridLayout.setColumnSpan(btn4, 3); GridLayout.setColumnSpan(btn4, 3);
// ``` // << grid-layout-columnspan
// ### Create ItemSpec for columns and rows 3 columns - 80px, *, auto size and 2 rows - 100px and auto size // >> grid-layout-itemspec
// ``` JavaScript
//// ItemSpec modes of the column refers to its width. //// ItemSpec modes of the column refers to its width.
//// Absolute size of the column //// Absolute size of the column
var firstColumn = new ItemSpec(80, GridUnitType.pixel); var firstColumn = new ItemSpec(80, GridUnitType.pixel);
@ -622,17 +603,15 @@ export class GridLayoutTest extends testModule.UITest<GridLayout> {
//// Star and Auto modes for rows behave like corresponding setting for columns but refer to row height. //// Star and Auto modes for rows behave like corresponding setting for columns but refer to row height.
var firstRow = new ItemSpec(1, GridUnitType.auto); var firstRow = new ItemSpec(1, GridUnitType.auto);
var secondRow = new ItemSpec(1, GridUnitType.star); var secondRow = new ItemSpec(1, GridUnitType.star);
// ``` // << grid-layout-itemspec
// ### Add columns and rows to GridLayout // >> grid-layout-add-rowscols
// ``` JavaScript
gridLayout.addColumn(firstColumn); gridLayout.addColumn(firstColumn);
gridLayout.addColumn(secondColumn); gridLayout.addColumn(secondColumn);
gridLayout.addColumn(thirdColumn); gridLayout.addColumn(thirdColumn);
gridLayout.addRow(firstRow); gridLayout.addRow(firstRow);
gridLayout.addRow(secondRow); gridLayout.addRow(secondRow);
// ``` // << grid-layout-add-rowscols
// </snippet>
} }
public test_percent_support() { public test_percent_support() {

View File

@ -0,0 +1,37 @@
---
nav-title: "grid-layout How-To"
title: "How-To"
description: "Examples for using grid-layout"
---
## GridLayout sample
### Creating Grid Layout via code.
<snippet id='grid-layout-require'/>
### Create grid layout with an xml declaration
``` XML
<GridLayout columns="80, *, auto" rows="auto, *" >
<Button col="0" />
<Button col="1" />
<Button col="2" />
// by default column and row are set to 0
<Button row="1" colSpan="3" />
</GridLayout>
```
### Add views to grid layout
<snippet id='grid-layout-addviews'/>
### Set column property on views - btn1 in first column, btn2 is second and btn3 in third
<snippet id='grid-layout-setcolumn'/>
### Set row property on btn4.
<snippet id='grid-layout-setrow'/>
### Set columnSpan property on btn4 to stretch into all columns
<snippet id='grid-layout-columnspan'/>
### Create ItemSpec for columns and rows 3 columns - 80px, *, auto size and 2 rows - 100px and auto size
<snippet id='grid-layout-itemspec'/>
### Add columns and rows to GridLayout
<snippet id='grid-layout-add-rowscols'/>

View File

@ -161,42 +161,28 @@ export class StackLayoutTest extends testModule.UITest<StackLayout> {
} }
public test_codesnippets() { public test_codesnippets() {
// <snippet module="ui/layouts/stack-layout" title="stack-layout">
// ### import StackLayout and Button classes // >> stack-layout-new
// var StackLayout = require("ui/layouts/stack-layout").StackLayout; // var StackLayout = require("ui/layouts/stack-layout").StackLayout;
// >> (hide)
// var Button = require("ui/button").Button; // var Button = require("ui/button").Button;
// ### Create StackLayout // << (hide)
// ``` JavaScript
var stackLayout = new StackLayout(); var stackLayout = new StackLayout();
// ``` // << stack-layout-new
// ### Declaring a StackLayout. // >> stack-layout-addchild
//``` XML
// <Page>
// <StackLayout orientation="horizontal">
// <Label text="This is Label 1" />
// </StackLayout>
// </Page>
//```
// </snippet>
// ### Add child view to layout
// ``` JavaScript
var btn = new Button(); var btn = new Button();
stackLayout.addChild(btn); stackLayout.addChild(btn);
// ``` // << stack-layout-addchild
// ### Remove child view from layout // >> stack-layout-remove
// ``` JavaScript
stackLayout.removeChild(btn); stackLayout.removeChild(btn);
// ``` // << stack-layout-remove
// ### Change layout orientation to Horizontal // >> stack-layout-horizontal
// ``` JavaScript
stackLayout.orientation = enums.Orientation.horizontal; stackLayout.orientation = enums.Orientation.horizontal;
// ``` // << stack-layout-horizontal
// </snippet>
} }
private setup_percent(): layoutHelper.MyButton { private setup_percent(): layoutHelper.MyButton {

View File

@ -0,0 +1,29 @@
---
nav-title: "stack-layout How-To"
title: "How-To"
description: "Examples for using stack-layout"
---
### import StackLayout and Button classes
var StackLayout = require("ui/layouts/stack-layout").StackLayout;
var Button = require("ui/button").Button;
### Create StackLayout
<snippet id='stack-layout-new'/>
### Declaring a StackLayout.
``` XML
<Page>
<StackLayout orientation="horizontal">
<Label text="This is Label 1" />
</StackLayout>
</Page>
```
### Add child view to layout
<snippet id='stack-layout-addchild'/>
### Remove child view from layout
<snippet id='stack-layout-remove'/>
### Change layout orientation to Horizontal
<snippet id='stack-layout-horizontal'/>

View File

@ -4,41 +4,20 @@ import layoutHelper = require("./layout-helper");
import testModule = require("../ui-test"); import testModule = require("../ui-test");
import commonTests = require("./common-layout-tests"); import commonTests = require("./common-layout-tests");
// <snippet module="ui/layouts/wrap-layout" title="WrapLayout"> // >> wrap-layout-require
// # WrapLayout
// Using a WrapLayout requires the WrapLayout module.
// ``` JavaScript
import wrapLayoutModule = require("ui/layouts/wrap-layout"); import wrapLayoutModule = require("ui/layouts/wrap-layout");
// ``` // << wrap-layout-require
// Other frequently used modules when working with a WrapLayout include: // >> wrap-layout-others
// ``` JavaScript
import enums = require("ui/enums"); import enums = require("ui/enums");
// ``` // << wrap-layout-others
// </snippet>
export class WrapLayoutTest extends testModule.UITest<wrapLayoutModule.WrapLayout> { export class WrapLayoutTest extends testModule.UITest<wrapLayoutModule.WrapLayout> {
public create(): wrapLayoutModule.WrapLayout { public create(): wrapLayoutModule.WrapLayout {
// <snippet module="ui/layouts/wrap-layout" title="WrapLayout"> // >> wrap-layout-new
// ## Creating a WrapLayout
// ``` JavaScript
var wrapLayout = new wrapLayoutModule.WrapLayout(); var wrapLayout = new wrapLayoutModule.WrapLayout();
// ``` // << wrap-layout-new
// </snippet>
// ### Declaring a WrapLayout.
//``` XML
// <Page>
// <WrapLayout>
// <Label text="This is Label 1" />
// <Label text="This is Label 2" />
// <Label text="This is Label 3" />
// <Label text="This is Label 4" />
// </WrapLayout>
// </Page>
//```
// </snippet>
wrapLayout.width = layoutHelper.dp(200); wrapLayout.width = layoutHelper.dp(200);
wrapLayout.height = layoutHelper.dp(200); wrapLayout.height = layoutHelper.dp(200);
@ -124,12 +103,9 @@ export class WrapLayoutTest extends testModule.UITest<wrapLayoutModule.WrapLayou
public testVerticalOrientation() { public testVerticalOrientation() {
var wrapLayout = this.testView; var wrapLayout = this.testView;
// <snippet module="ui/layouts/wrap-layout" title="WrapLayout"> // >> wrap-layout-orientation
// ## Setting the orientation of a wrap-layout.
// ``` JavaScript
wrapLayout.orientation = enums.Orientation.vertical; wrapLayout.orientation = enums.Orientation.vertical;
// ``` // << wrap-layout-orientation
// </snippet>
this.waitUntilTestElementLayoutIsValid(); this.waitUntilTestElementLayoutIsValid();
let actualValue = this.testView.getChildAt(0)._getCurrentLayoutBounds(); let actualValue = this.testView.getChildAt(0)._getCurrentLayoutBounds();

View File

@ -0,0 +1,29 @@
---
nav-title: "WrapLayout How-To"
title: "How-To"
description: "Examples for using WrapLayout"
---
# WrapLayout
Using a WrapLayout requires the WrapLayout module.
<snippet id='wrap-layout-require'/>
Other frequently used modules when working with a WrapLayout include:
<snippet id='wrap-layout-others'/>
## Creating a WrapLayout
<snippet id='wrap-layout-new'/>
### Declaring a WrapLayout.
``` XML
<Page>
<WrapLayout>
<Label text="This is Label 1" />
<Label text="This is Label 2" />
<Label text="This is Label 3" />
<Label text="This is Label 4" />
</WrapLayout>
</Page>
```
## Setting the orientation of a wrap-layout.
<snippet id='wrap-layout-orientation'/>