Skip to content

Commit 6b8ed42

Browse files
committed
Added Directives
1 parent c57df3d commit 6b8ed42

File tree

8 files changed

+655
-27
lines changed

8 files changed

+655
-27
lines changed

docs/collect.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,14 +127,23 @@ function escapedHtmlTag(doc, name, value) {
127127
}
128128

129129
function markdownTag(doc, name, value) {
130-
doc[name] = markdown(value.replace(/^#/gm, '##'));
130+
doc[name] = markdown(value.replace(/^#/gm, '##')).
131+
replace(/\<pre\>/gmi, '<pre class="brush: xml; brush: js;" ng:non-bindable>');
131132
}
132133

133134
function markdown(text) {
134135
text = text.replace(/<angular\/>/gm, '<tt>&lt;angular/&gt;</tt>');
135136
return new Showdown.converter().makeHtml(text);
136137
}
137138

139+
function markdownNoP(text) {
140+
var lines = markdown(text).split(NEW_LINE);
141+
var last = lines.length - 1;
142+
lines[0] = lines[0].replace(/^<p>/, '');
143+
lines[last] = lines[last].replace(/<\/p>$/, '');
144+
return lines.join('\n');
145+
}
146+
138147
var TAG = {
139148
ngdoc: valueTag,
140149
example: escapedHtmlTag,
@@ -149,6 +158,7 @@ var TAG = {
149158
returns: markdownTag,
150159
paramDescription: markdownTag,
151160
exampleDescription: markdownTag,
161+
element: valueTag,
152162
name: function(doc, name, value) {
153163
doc.name = value;
154164
var match = value.match(/^angular[\.\#](([^\.]+)\.(.*)|(.*))/);
@@ -163,7 +173,7 @@ var TAG = {
163173
type: match[2],
164174
name: match[6] || match[5],
165175
'default':match[7],
166-
description:value.replace(match[0], match[8])
176+
description:markdownNoP(value.replace(match[0], match[8]))
167177
};
168178
doc.param.push(param);
169179
if (!doc.paramFirst) {

docs/directive.template

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<h1>{{name}}</h1>
2+
<h2>Description</h2>
3+
{{{description}}}
4+
5+
<h2>Usage</h2>
6+
<h3>In HTML Template Binding</h3>
7+
<tt>
8+
<pre>
9+
&lt;{{element}} {{shortName}}="{{paramFirst.name}}"&gt;
10+
...
11+
&lt;/{{element}}&gt;
12+
</pre>
13+
</tt>
14+
15+
<h3>Parameters</h3>
16+
<ul>
17+
{{#param}}
18+
<li><tt>{{name}}:{{#type}}{{type}}{{/type}}{{^type}}:*{{/type}}{{#default}}={{default}}{{/default}}</tt>: {{{description}}}</li>
19+
{{/param}}
20+
</ul>
21+
{{{paramDescription}}}
22+
23+
{{#css}}<h3>CSS</h3>{{/css}}
24+
{{{css}}}
25+
26+
{{#example}}
27+
<h2>Example</h2>
28+
{{{exampleDescription}}}
29+
<doc:example>
30+
<doc:source>
31+
{{/example}}
32+
{{{example}}}
33+
{{#example}}
34+
</doc:source>
35+
<doc:scenario>{{{scenario}}}</doc:scenario>
36+
</doc:example>
37+
{{/example}}

docs/doc_widgets.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
var tabs = angular.element(
2424
'<ul class="doc-example">' +
2525
'<li class="doc-example-heading"><h3>Source</h3></li>' +
26-
'<li class="doc-example-source" ng:non-bindable><pre class="brush: js"></pre></li>' +
26+
'<li class="doc-example-source" ng:non-bindable><pre class="brush: js; brush: xml;"></pre></li>' +
2727
'<li class="doc-example-heading"><h3>Live Preview</h3></li>' +
2828
'<li class="doc-example-live">' + exampleSrc +'</li>' +
2929
'<li class="doc-example-heading"><h3>Scenario Test</h3></li>' +
@@ -44,6 +44,6 @@
4444

4545
return function() {
4646
SyntaxHighlighter.highlight();
47-
}
47+
};
4848
});
4949
})();

docs/index.html

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!DOCTYPE HTML>
2-
<html xmlns:ng="http://angularjs.org/" xmlns:doc="http://docs.angularjs.org/">
2+
<html xmlns:ng="http://angularjs.org/" xmlns:doc="http://docs.angularjs.org/" ng:controller="DocsController">
33
<head>
44
<title>&lt;Angular/&gt; Docs</title>
55
<link rel="stylesheet" href="wiki_widgets.css" type="text/css" media="screen">
@@ -11,32 +11,33 @@
1111
<script type="text/javascript" src="doc_widgets.js"></script>
1212
<script type="text/javascript" src="http://alexgorbatchev.com/pub/sh/current/scripts/shCore.js"></script>
1313
<script type="text/javascript" src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJScript.js"></script>
14+
<script type="text/javascript" src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushXml.js"></script>
1415
<script type="text/javascript" src="docs-data.js"></script>
1516
<script type="text/javascript">
1617
SyntaxHighlighter['defaults'].toolbar = false;
1718

18-
DocsController.$inject = ['$location']
19-
function DocsController($location) {
19+
DocsController.$inject = ['$location', '$browser']
20+
function DocsController($location, $browser) {
2021
this.docs = NG_DOC;
2122
window.$root = this.$root;
22-
23+
2324
this.getUrl = function(page){
2425
return '#' + encodeURIComponent(page.name);
2526
};
2627

27-
this.getTitle = function() {
28-
if ($location.hashPath.match(/^angular\./)) {
29-
return $location.hashPath;
30-
}
31-
return '';
32-
};
33-
3428
this.getCurrentPartial = function(){
3529
if ($location.hashPath.match(/^angular\./)) {
3630
this.partialUrl = './' + $location.hashPath + '.html';
3731
}
3832
return this.partialUrl;
39-
};
33+
}
34+
35+
this.getTitle = function(){
36+
if ($location.hashPath.match(/^angular\./)) {
37+
this.partialTitle = $location.hashPath;
38+
}
39+
return this.partialTitle;
40+
}
4041
}
4142
</script>
4243
<style type="text/css" media="screen">
@@ -122,8 +123,9 @@
122123
float: right;
123124
}
124125
</style>
126+
<title>&lt;angular/&gt;: {{getTitle()}}</title>
125127
</head>
126-
<body ng:controller="DocsController">
128+
<body>
127129
<div id="header">
128130
<h1>
129131
<span class="section-title">{{getTitle()}}</span>
@@ -134,7 +136,7 @@ <h1>
134136
<div ng:repeat="(name, type) in docs.section" class="nav-section">
135137
<h2>{{name}}</h2>
136138
<ul>
137-
<li ng:repeat="page in type">
139+
<li ng:repeat="page in type.$orderBy('shortName')">
138140
<a href="{{getUrl(page)}}" ng:click="">{{page.shortName}}</a>
139141
</li>
140142
</ul>

docs/spec/collectSpec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ describe('collect', function(){
4343

4444
describe('@describe', function(){
4545
it('should support pre blocks', function(){
46-
TAG.description(doc, 'description', '<pre>abc</pre>');
47-
expect(doc.description).toEqual('<pre>abc</pre>');
46+
TAG.description(doc, 'description', '<pre class="brush: xml;" ng:non-bindable>abc</pre>');
47+
expect(doc.description).toEqual('<pre class="brush: xml;" ng:non-bindable>abc</pre>');
4848
});
4949

5050
describe('@example', function(){

src/Angular.js

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ var lowercase = function (value){ return isString(value) ? value.toLowerCase() :
1717

1818
/**
1919
* @ngdoc
20-
* @name angular#uppercase
20+
* @name angular.uppercase
2121
* @function
2222
*
2323
* @description Converts string to uppercase.
@@ -150,6 +150,21 @@ var _undefined = undefined,
150150
* };
151151
* });
152152
* </pre>
153+
*
154+
* @example
155+
* <script>
156+
* angular.widget('my:time', function(compileElement){
157+
* compileElement.css('display', 'block');
158+
* return function(linkElement){
159+
* function update(){
160+
* linkElement.text('Current time is: ' + new Date());
161+
* setTimeout(update, 1000);
162+
* }
163+
* update();
164+
* };
165+
* });
166+
* </script>
167+
* <my:time></my:time>
153168
*/
154169
angularWidget = extensionMap(angular, 'widget', lowercase),
155170

@@ -366,15 +381,19 @@ var _undefined = undefined,
366381
* });
367382
* </script>
368383
*
369-
* Formatted: <input type="text" name="data" value="&lt;angular/&gt;" ng:format="reverse"/><br/>
370-
* Stored: <input type="text" name="data"/><br/>
384+
* Formatted:
385+
* <input type="text" name="data" value="angular" ng:format="reverse"/>
386+
* <br/>
387+
*
388+
* Stored:
389+
* <input type="text" name="data"/><br/>
371390
* <pre>{{data}}</pre>
372391
*
373392
*
374393
* @scenario
375394
* it('should store reverse', function(){
376-
* expect(element('.doc-example input:first').val()).toEqual('<angular/>');
377-
* expect(element('.doc-example input:last').val()).toEqual('>/RALUGNA<');
395+
* expect(element('.doc-example input:first').val()).toEqual('angular');
396+
* expect(element('.doc-example input:last').val()).toEqual('RALUGNA');
378397
*
379398
* this.addFutureAction('change to XYZ', function($window, $document, done){
380399
* $document.elements('.doc-example input:last').val('XYZ').trigger('change');

0 commit comments

Comments
 (0)