summaryrefslogtreecommitdiffstats
path: root/lib/models/summaryArticle.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/models/summaryArticle.js')
-rw-r--r--lib/models/summaryArticle.js84
1 files changed, 48 insertions, 36 deletions
diff --git a/lib/models/summaryArticle.js b/lib/models/summaryArticle.js
index f072e7b..9b5b653 100644
--- a/lib/models/summaryArticle.js
+++ b/lib/models/summaryArticle.js
@@ -30,20 +30,20 @@ SummaryArticle.prototype.getArticles = function() {
};
/**
- Return how deep the article is.
- The README has a depth of 1
-
- @return {Number}
-*/
+ * Return how deep the article is.
+ * The README has a depth of 1
+ *
+ * @return {Number}
+ */
SummaryArticle.prototype.getDepth = function() {
return (this.getLevel().split('.').length - 1);
};
/**
- Get path (without anchor) to the pointing file
-
- @return {String}
-*/
+ * Get path (without anchor) to the pointing file
+ *
+ * @return {String}
+ */
SummaryArticle.prototype.getPath = function() {
if (this.isExternal()) {
return undefined;
@@ -63,19 +63,19 @@ SummaryArticle.prototype.getPath = function() {
};
/**
- Return url if article is external
-
- @return {String}
-*/
+ * Return url if article is external
+ *
+ * @return {String}
+ */
SummaryArticle.prototype.getUrl = function() {
return this.isExternal()? this.getRef() : undefined;
};
/**
- Get anchor for this article (or undefined)
-
- @return {String}
-*/
+ * Get anchor for this article (or undefined)
+ *
+ * @return {String}
+ */
SummaryArticle.prototype.getAnchor = function() {
var ref = this.getRef();
var parts = ref.split('#');
@@ -85,29 +85,42 @@ SummaryArticle.prototype.getAnchor = function() {
};
/**
- Is article pointing to a page of an absolute url
+ * Create a new level for a new child article
+ *
+ * @return {String}
+ */
+SummaryArticle.prototype.createChildLevel = function() {
+ var level = this.getLevel();
+ var subArticles = this.getArticles();
+ var childLevel = level + '.' + (subArticles.size + 1);
+
+ return childLevel;
+};
- @return {Boolean}
-*/
+/**
+ * Is article pointing to a page of an absolute url
+ *
+ * @return {Boolean}
+ */
SummaryArticle.prototype.isPage = function() {
return !this.isExternal() && this.getRef();
};
/**
- Is article pointing to aan absolute url
-
- @return {Boolean}
-*/
+ * Is article pointing to aan absolute url
+ *
+ * @return {Boolean}
+ */
SummaryArticle.prototype.isExternal = function() {
return location.isExternal(this.getRef());
};
/**
- Create a SummaryArticle
-
- @param {Object} def
- @return {SummaryArticle}
-*/
+ * Create a SummaryArticle
+ *
+ * @param {Object} def
+ * @return {SummaryArticle}
+ */
SummaryArticle.create = function(def, level) {
var articles = (def.articles || []).map(function(article, i) {
if (article instanceof SummaryArticle) {
@@ -124,14 +137,13 @@ SummaryArticle.create = function(def, level) {
});
};
-
/**
- Find an article from a base one
-
- @param {Article|Part} base
- @param {Function(article)} iter
- @return {Article}
-*/
+ * Find an article from a base one
+ *
+ * @param {Article|Part} base
+ * @param {Function(article)} iter
+ * @return {Article}
+ */
SummaryArticle.findArticle = function(base, iter) {
var articles = base.getArticles();