Currently there is lots of inconsistency in how code is referenced by name. This leads to complex and difficult to maintain code. Instead we should agree on a consistent naming scheme as follows:
- Each code component should have a well defined
id
based on their module, name and type. - Everything exists in a module (even globals since they are loaded along with a module such as ng or ngMock).
- Special kinds of component should be highlighted - modules, directives, filters and globals - using a scoping syntax, the type of the component followed by a colon prefixed to the component name.
- Services are just objects (or functions) and would not need to be prefixed
- Types are just constructor functions defined either globally or as a service in a module. They should be identifiable through starting with a upper case letter so they should not need a special component type.
- Input directives have sub-types, such as
checkbox
ortext
. These should be incorporated into the component name using square bracketsinput[checkbox]
. - Methods on components should be defined by # fragments, which will be simply appended to the URL and allow the browser to navigate directly to the documentation for that item in the page:
This scheme makes is consistent to convert back and forth between ids and paths.
module:ngSanitize
module:ng.filter:currency
module:ng.directive:input[checkbox]
module:ngRoute.directive:ngView
module:ngMock.global:angular.mock.dump
module:ngResource.$resource
module:ng.global:form.FormController
module:ng.$http#methods_head
The ids above would map to the following URL paths, also making a nice path hierarchy:
ngSanitize
ng/filter/currency
ng/directive/input[checkbox]
ngRoute/directive/ngView
ngMock/global/angular.mock.dump
ngResource/service/$resource
ng/global/form.FormController
ng/$http#methods_head
Since we have all the documents in a single collection during processing, we can do clever matching of links against code names. This means that you only have to provide enough of a components id to identify it unambiguously relative to other components in the collection. For example, in the AngularJS code we can refer to many components simply by their "name":
ngShow
$route
ngSanitize
But were there is ambiguity we need to add progressively more information:
ngMock:$log
ngMockE2E:$httpBackend
Currently the @ngdoc
tag can contain one of the following values:
error
- only used for minerr documentationfunction
- generally used for global functions but sometimes "misused" for a service or methodproperty
- generally used for properties on services but also used forangular.version
overview
- generally used for modules and ngdocs but also used forng.$rootElement
andangular.mock
(should be objects?)object
- generally used for services that are not straight functionsmethod
- used for methods on services and types (such asangular.Module
, etc)interface
- only used forangular.Module
inangular-load.js
service
- used only occasionally for some angular servicesdirective
- used for angular directivesinputType
- used for input element specific directives (such asinput[checkbox]
)event
- used for events on objects (mostly services)filter
- used for angular filters (although there may be one or two that use function)
We ought to consolidate to:
function
- for global functionsobject
- for global objectsinterface
- for global interfacestype
- for constructorsmodule
- instead ofoverview
for modulesservice
- instead of object/function for angular servicesserviceProvider
- instead of function/object for angular service providersdirective
- as-is (but also include inputTypes, e.g input[checkbox])filter
- as-ismethod
- as-isproperty
- as-is (but change angular.version to object)event
- as-is- Anything else is just a descriptive name for the content, such as
error
,guide
,tutorial
, etc.
Currently the source folder structure for errors doesn't match the urls and names of the errors
because we are using things like compile
instead of $compile
. We should change this to make it
more consistent. (Not immediately essential as we currently generate the @id
from the @name
in
any case).
We should lose the flat structure and create folder hierarchies for the source files that will map to the URL paths to the guide documents
E.g. content/guide/dev_guide.services.injecting_controllers.ngdoc
should become
content/guide/services/injecting_controllers.ngdoc
This could be done as an angular directive rather than the custom //!annotate solution
For example, in ngShow:
* If you wish to change the hide behavior with ngShow/ngHide then this can be achieved by
* restating the styles for the .ng-hide class in CSS:
* <pre>
* .ng-hide {
* <div annotation title="CSS Specificity" content="Not to worry, this will override the AngularJS default...">
* display:block!important;
* </div>
*
* //this is just another form of hiding an element
* position:absolute;
* top:-9999px;
* left:-9999px;
* }
* </pre>
Or in ngAnimate
<pre class="prettyprint linenums">
var ngModule = angular.module(<div annotation title="Your AngularJS Module" content="Replace this or ngModule with the module that you used to define your application.">'YourApp'</div>, ['ngAnimate']);
ngModule.animation('.my-crazy-animation', function() {
return {
enter(element, done) {
//run the animation here and call done when the animation is complete
return function(cancelled) {