-
Notifications
You must be signed in to change notification settings - Fork 9
feat(Ruby): add intro sentence to summary with friendly api name #373
Changes from 32 commits
99f2b83
914c36b
8fb693a
481a153
a11becb
daa5d46
709c853
d7470a6
c77894a
8181f80
da85678
044183e
1746065
f4446c5
45a7ad7
21defef
205c633
0431dc1
0712881
410544f
0d3fcd5
343c2a9
225ca90
899de43
3e745da
7404c03
eec6698
e6f0e1a
50fc32c
8962579
bee4860
af2ddf2
a475c36
d272521
df33ebd
43f816a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,4 +25,4 @@ exports.getOptions = function (model) { | |
return { | ||
"bookmarks": urefCommon.getBookmarks(model) | ||
}; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ exports.isAbsolutePath = isAbsolutePath; | |
exports.isRelativePath = isRelativePath; | ||
|
||
exports.getTitleForTypeProperty = getTitleForTypeProperty; | ||
exports.addIntroSentenceToSummary = addIntroSentenceToSummary; | ||
|
||
function getFileNameWithoutExtension(path) { | ||
if (!path || path[path.length - 1] === '/' || path[path.length - 1] === '\\') return ''; | ||
|
@@ -107,6 +108,30 @@ function getTitleForTypeProperty(type, name, uid) { | |
} | ||
} | ||
|
||
/** | ||
* Updates summary with an intro sentence containing the friendly API name. | ||
* | ||
* @param {string} summary The summary for the item. | ||
* @param {string} type The type for the item (i.e. class, module). | ||
* @param {string} friendlyApiName The friendly API title for the item. | ||
* @param {Array} name The names for the item, only the first item is used for forming the sentence. | ||
*/ | ||
function addIntroSentenceToSummary(summary, friendlyApiName, type, name) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks fairly complicated compared to adding it to the mustache template. How about doing this in the template instead with something like...
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It gets complicated when including the object's type in the sentence. I factored out the type addition to title so we wouldn't have to have a partial file for that. This would be similar: we'd need to have a partial for switching based on type. In general, I think we should try to avoid hard-coding language in the template -- it makes things like language updates and localization efforts more difficult. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We won't be doing localization based on the template given here. That's fine. Another consideration is to add this for now into the Ruby YAMLs to begin with, which would be easier to find all the values rather than trying to compute and figure out what we need to extract from the YAMLs. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Discussed offline, in summary: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure I understand. Feels funny to be dealing with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤦🏻♂️, right that'd be a good idea! I put the |
||
if (summary == null || !type || !name) return summary; | ||
if (!titlePrefixForTypeProperty[type]) return summary; | ||
|
||
summaryIntro = "<p>" | ||
summaryIntro += "Reference documentation and code samples for the "; | ||
summaryIntro += friendlyApiName; | ||
summaryIntro += " "; | ||
summaryIntro += titlePrefixForTypeProperty[type].toLowerCase(); | ||
summaryIntro += " "; | ||
summaryIntro += name[0].value; | ||
summaryIntro += "." | ||
summaryIntro += "</p>"; | ||
return summaryIntro + summary; | ||
} | ||
|
||
var gitUrlPatternItems = { | ||
'github': { | ||
// HTTPS form: https://github.com/{org}/{repo}.git | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How are the two different?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This allows us to modify a summary that is an empty string. Without the distinction, we won't be able to add this sentence for pages contain an empty summary, but do have a
summary
key in the yaml.