mirror of
https://github.com/phpredis/phpredis.git
synced 2026-06-19 07:35:31 +00:00
Additional doctum syntax highlighting. (#2763)
* docs: Syntax highlight ```php ... ``` code blocks * docs: More syntax highlighting * docs: Allow `highlight.js` to syntax highlight `Redis`. * docs: Rebuild doctum static files
This commit is contained in:
+1659
-899
File diff suppressed because it is too large
Load Diff
+1294
-556
File diff suppressed because it is too large
Load Diff
+1214
-516
File diff suppressed because it is too large
Load Diff
@@ -24,6 +24,45 @@
|
||||
return;
|
||||
}
|
||||
|
||||
function ensureCustomClassesAreBuiltIn() {
|
||||
var classesToAdd = ['Redis', 'RedisCluster', 'RedisArray'];
|
||||
|
||||
if (!hljs.getLanguage) {
|
||||
return;
|
||||
}
|
||||
|
||||
var phpLanguage = hljs.getLanguage('php');
|
||||
if (!phpLanguage || !phpLanguage.keywords) {
|
||||
return;
|
||||
}
|
||||
|
||||
var builtIns = phpLanguage.keywords.built_in;
|
||||
if (!builtIns) {
|
||||
phpLanguage.keywords.built_in = classesToAdd.join(' ');
|
||||
return;
|
||||
}
|
||||
|
||||
if (Array.isArray(builtIns)) {
|
||||
classesToAdd.forEach(function (className) {
|
||||
if (builtIns.indexOf(className) === -1) {
|
||||
builtIns.push(className);
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (typeof builtIns === 'string') {
|
||||
classesToAdd.forEach(function (className) {
|
||||
if (builtIns.indexOf(className) === -1) {
|
||||
builtIns += ' ' + className;
|
||||
}
|
||||
});
|
||||
phpLanguage.keywords.built_in = builtIns;
|
||||
}
|
||||
}
|
||||
|
||||
ensureCustomClassesAreBuiltIn();
|
||||
|
||||
var exampleBlocks = document.querySelectorAll('pre.examples');
|
||||
exampleBlocks.forEach(function (block) {
|
||||
if (!block.dataset.language) {
|
||||
@@ -40,6 +79,149 @@
|
||||
}
|
||||
hljs.highlightElement(block);
|
||||
});
|
||||
|
||||
var phpCodeBlocks = document.querySelectorAll('pre code.language-php');
|
||||
phpCodeBlocks.forEach(function (block) {
|
||||
if (block.classList.contains('method-signature')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (block.closest('pre.examples')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (block.parentElement && !block.parentElement.classList.contains('language-php')) {
|
||||
block.parentElement.classList.add('language-php');
|
||||
}
|
||||
|
||||
hljs.highlightElement(block);
|
||||
});
|
||||
|
||||
highlightReturnTypes();
|
||||
|
||||
function highlightReturnTypes() {
|
||||
if (!document.createTreeWalker || !window.NodeFilter) {
|
||||
return;
|
||||
}
|
||||
|
||||
var containers = document.querySelectorAll('.return-value-content');
|
||||
containers.forEach(function (container) {
|
||||
var table = container.querySelector('table');
|
||||
if (!table) {
|
||||
return;
|
||||
}
|
||||
|
||||
table.querySelectorAll('tr').forEach(function (row) {
|
||||
var typeCell = row.querySelector('td');
|
||||
if (!typeCell || typeCell.querySelector('code.return-type')) {
|
||||
return;
|
||||
}
|
||||
|
||||
var typeText = typeCell.textContent.trim();
|
||||
if (!typeText) {
|
||||
return;
|
||||
}
|
||||
|
||||
var linkMeta = collectLinkMetadata(typeCell, typeText);
|
||||
var code = document.createElement('code');
|
||||
code.className = 'return-type language-php';
|
||||
code.textContent = typeText;
|
||||
|
||||
typeCell.innerHTML = '';
|
||||
typeCell.appendChild(code);
|
||||
|
||||
hljs.highlightElement(code);
|
||||
|
||||
if (linkMeta.length) {
|
||||
restoreLinks(code, linkMeta);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function collectLinkMetadata(cell, typeText) {
|
||||
var anchors = cell.querySelectorAll('a');
|
||||
var lastIndex = 0;
|
||||
var meta = [];
|
||||
|
||||
anchors.forEach(function (anchor) {
|
||||
var text = anchor.textContent.trim();
|
||||
if (!text) {
|
||||
return;
|
||||
}
|
||||
|
||||
var href = anchor.getAttribute('href');
|
||||
var start = typeText.indexOf(text, lastIndex);
|
||||
|
||||
if (start === -1) {
|
||||
start = typeText.indexOf(text);
|
||||
if (start === -1) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
meta.push({
|
||||
start: start,
|
||||
end: start + text.length,
|
||||
href: href
|
||||
});
|
||||
|
||||
lastIndex = start + text.length;
|
||||
});
|
||||
|
||||
return meta;
|
||||
}
|
||||
|
||||
function restoreLinks(codeElement, meta) {
|
||||
var sorted = meta.slice().sort(function (a, b) {
|
||||
return b.start - a.start;
|
||||
});
|
||||
|
||||
sorted.forEach(function (info) {
|
||||
var startPos = findTextPosition(codeElement, info.start);
|
||||
var endPos = findTextPosition(codeElement, info.end);
|
||||
|
||||
if (!startPos || !endPos) {
|
||||
return;
|
||||
}
|
||||
|
||||
var range = document.createRange();
|
||||
range.setStart(startPos.node, startPos.offset);
|
||||
range.setEnd(endPos.node, endPos.offset);
|
||||
|
||||
var anchor = document.createElement('a');
|
||||
anchor.setAttribute('href', info.href);
|
||||
anchor.appendChild(range.extractContents());
|
||||
range.insertNode(anchor);
|
||||
range.detach();
|
||||
});
|
||||
}
|
||||
|
||||
function findTextPosition(container, targetIndex) {
|
||||
var walker = document.createTreeWalker(
|
||||
container,
|
||||
NodeFilter.SHOW_TEXT,
|
||||
null
|
||||
);
|
||||
|
||||
var currentIndex = 0;
|
||||
var currentNode;
|
||||
|
||||
while ((currentNode = walker.nextNode())) {
|
||||
var nextIndex = currentIndex + currentNode.textContent.length;
|
||||
|
||||
if (targetIndex <= nextIndex) {
|
||||
return {
|
||||
node: currentNode,
|
||||
offset: targetIndex - currentIndex
|
||||
};
|
||||
}
|
||||
|
||||
currentIndex = nextIndex;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
@@ -24,6 +24,45 @@
|
||||
return;
|
||||
}
|
||||
|
||||
function ensureCustomClassesAreBuiltIn() {
|
||||
var classesToAdd = ['Redis', 'RedisCluster', 'RedisArray'];
|
||||
|
||||
if (!hljs.getLanguage) {
|
||||
return;
|
||||
}
|
||||
|
||||
var phpLanguage = hljs.getLanguage('php');
|
||||
if (!phpLanguage || !phpLanguage.keywords) {
|
||||
return;
|
||||
}
|
||||
|
||||
var builtIns = phpLanguage.keywords.built_in;
|
||||
if (!builtIns) {
|
||||
phpLanguage.keywords.built_in = classesToAdd.join(' ');
|
||||
return;
|
||||
}
|
||||
|
||||
if (Array.isArray(builtIns)) {
|
||||
classesToAdd.forEach(function (className) {
|
||||
if (builtIns.indexOf(className) === -1) {
|
||||
builtIns.push(className);
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (typeof builtIns === 'string') {
|
||||
classesToAdd.forEach(function (className) {
|
||||
if (builtIns.indexOf(className) === -1) {
|
||||
builtIns += ' ' + className;
|
||||
}
|
||||
});
|
||||
phpLanguage.keywords.built_in = builtIns;
|
||||
}
|
||||
}
|
||||
|
||||
ensureCustomClassesAreBuiltIn();
|
||||
|
||||
var exampleBlocks = document.querySelectorAll('pre.examples');
|
||||
exampleBlocks.forEach(function (block) {
|
||||
if (!block.dataset.language) {
|
||||
@@ -40,6 +79,149 @@
|
||||
}
|
||||
hljs.highlightElement(block);
|
||||
});
|
||||
|
||||
var phpCodeBlocks = document.querySelectorAll('pre code.language-php');
|
||||
phpCodeBlocks.forEach(function (block) {
|
||||
if (block.classList.contains('method-signature')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (block.closest('pre.examples')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (block.parentElement && !block.parentElement.classList.contains('language-php')) {
|
||||
block.parentElement.classList.add('language-php');
|
||||
}
|
||||
|
||||
hljs.highlightElement(block);
|
||||
});
|
||||
|
||||
highlightReturnTypes();
|
||||
|
||||
function highlightReturnTypes() {
|
||||
if (!document.createTreeWalker || !window.NodeFilter) {
|
||||
return;
|
||||
}
|
||||
|
||||
var containers = document.querySelectorAll('.return-value-content');
|
||||
containers.forEach(function (container) {
|
||||
var table = container.querySelector('table');
|
||||
if (!table) {
|
||||
return;
|
||||
}
|
||||
|
||||
table.querySelectorAll('tr').forEach(function (row) {
|
||||
var typeCell = row.querySelector('td');
|
||||
if (!typeCell || typeCell.querySelector('code.return-type')) {
|
||||
return;
|
||||
}
|
||||
|
||||
var typeText = typeCell.textContent.trim();
|
||||
if (!typeText) {
|
||||
return;
|
||||
}
|
||||
|
||||
var linkMeta = collectLinkMetadata(typeCell, typeText);
|
||||
var code = document.createElement('code');
|
||||
code.className = 'return-type language-php';
|
||||
code.textContent = typeText;
|
||||
|
||||
typeCell.innerHTML = '';
|
||||
typeCell.appendChild(code);
|
||||
|
||||
hljs.highlightElement(code);
|
||||
|
||||
if (linkMeta.length) {
|
||||
restoreLinks(code, linkMeta);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function collectLinkMetadata(cell, typeText) {
|
||||
var anchors = cell.querySelectorAll('a');
|
||||
var lastIndex = 0;
|
||||
var meta = [];
|
||||
|
||||
anchors.forEach(function (anchor) {
|
||||
var text = anchor.textContent.trim();
|
||||
if (!text) {
|
||||
return;
|
||||
}
|
||||
|
||||
var href = anchor.getAttribute('href');
|
||||
var start = typeText.indexOf(text, lastIndex);
|
||||
|
||||
if (start === -1) {
|
||||
start = typeText.indexOf(text);
|
||||
if (start === -1) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
meta.push({
|
||||
start: start,
|
||||
end: start + text.length,
|
||||
href: href
|
||||
});
|
||||
|
||||
lastIndex = start + text.length;
|
||||
});
|
||||
|
||||
return meta;
|
||||
}
|
||||
|
||||
function restoreLinks(codeElement, meta) {
|
||||
var sorted = meta.slice().sort(function (a, b) {
|
||||
return b.start - a.start;
|
||||
});
|
||||
|
||||
sorted.forEach(function (info) {
|
||||
var startPos = findTextPosition(codeElement, info.start);
|
||||
var endPos = findTextPosition(codeElement, info.end);
|
||||
|
||||
if (!startPos || !endPos) {
|
||||
return;
|
||||
}
|
||||
|
||||
var range = document.createRange();
|
||||
range.setStart(startPos.node, startPos.offset);
|
||||
range.setEnd(endPos.node, endPos.offset);
|
||||
|
||||
var anchor = document.createElement('a');
|
||||
anchor.setAttribute('href', info.href);
|
||||
anchor.appendChild(range.extractContents());
|
||||
range.insertNode(anchor);
|
||||
range.detach();
|
||||
});
|
||||
}
|
||||
|
||||
function findTextPosition(container, targetIndex) {
|
||||
var walker = document.createTreeWalker(
|
||||
container,
|
||||
NodeFilter.SHOW_TEXT,
|
||||
null
|
||||
);
|
||||
|
||||
var currentIndex = 0;
|
||||
var currentNode;
|
||||
|
||||
while ((currentNode = walker.nextNode())) {
|
||||
var nextIndex = currentIndex + currentNode.textContent.length;
|
||||
|
||||
if (targetIndex <= nextIndex) {
|
||||
return {
|
||||
node: currentNode,
|
||||
offset: targetIndex - currentIndex
|
||||
};
|
||||
}
|
||||
|
||||
currentIndex = nextIndex;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
+226
-22
@@ -24,6 +24,45 @@
|
||||
return;
|
||||
}
|
||||
|
||||
function ensureCustomClassesAreBuiltIn() {
|
||||
var classesToAdd = ['Redis', 'RedisCluster', 'RedisArray'];
|
||||
|
||||
if (!hljs.getLanguage) {
|
||||
return;
|
||||
}
|
||||
|
||||
var phpLanguage = hljs.getLanguage('php');
|
||||
if (!phpLanguage || !phpLanguage.keywords) {
|
||||
return;
|
||||
}
|
||||
|
||||
var builtIns = phpLanguage.keywords.built_in;
|
||||
if (!builtIns) {
|
||||
phpLanguage.keywords.built_in = classesToAdd.join(' ');
|
||||
return;
|
||||
}
|
||||
|
||||
if (Array.isArray(builtIns)) {
|
||||
classesToAdd.forEach(function (className) {
|
||||
if (builtIns.indexOf(className) === -1) {
|
||||
builtIns.push(className);
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (typeof builtIns === 'string') {
|
||||
classesToAdd.forEach(function (className) {
|
||||
if (builtIns.indexOf(className) === -1) {
|
||||
builtIns += ' ' + className;
|
||||
}
|
||||
});
|
||||
phpLanguage.keywords.built_in = builtIns;
|
||||
}
|
||||
}
|
||||
|
||||
ensureCustomClassesAreBuiltIn();
|
||||
|
||||
var exampleBlocks = document.querySelectorAll('pre.examples');
|
||||
exampleBlocks.forEach(function (block) {
|
||||
if (!block.dataset.language) {
|
||||
@@ -40,6 +79,149 @@
|
||||
}
|
||||
hljs.highlightElement(block);
|
||||
});
|
||||
|
||||
var phpCodeBlocks = document.querySelectorAll('pre code.language-php');
|
||||
phpCodeBlocks.forEach(function (block) {
|
||||
if (block.classList.contains('method-signature')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (block.closest('pre.examples')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (block.parentElement && !block.parentElement.classList.contains('language-php')) {
|
||||
block.parentElement.classList.add('language-php');
|
||||
}
|
||||
|
||||
hljs.highlightElement(block);
|
||||
});
|
||||
|
||||
highlightReturnTypes();
|
||||
|
||||
function highlightReturnTypes() {
|
||||
if (!document.createTreeWalker || !window.NodeFilter) {
|
||||
return;
|
||||
}
|
||||
|
||||
var containers = document.querySelectorAll('.return-value-content');
|
||||
containers.forEach(function (container) {
|
||||
var table = container.querySelector('table');
|
||||
if (!table) {
|
||||
return;
|
||||
}
|
||||
|
||||
table.querySelectorAll('tr').forEach(function (row) {
|
||||
var typeCell = row.querySelector('td');
|
||||
if (!typeCell || typeCell.querySelector('code.return-type')) {
|
||||
return;
|
||||
}
|
||||
|
||||
var typeText = typeCell.textContent.trim();
|
||||
if (!typeText) {
|
||||
return;
|
||||
}
|
||||
|
||||
var linkMeta = collectLinkMetadata(typeCell, typeText);
|
||||
var code = document.createElement('code');
|
||||
code.className = 'return-type language-php';
|
||||
code.textContent = typeText;
|
||||
|
||||
typeCell.innerHTML = '';
|
||||
typeCell.appendChild(code);
|
||||
|
||||
hljs.highlightElement(code);
|
||||
|
||||
if (linkMeta.length) {
|
||||
restoreLinks(code, linkMeta);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function collectLinkMetadata(cell, typeText) {
|
||||
var anchors = cell.querySelectorAll('a');
|
||||
var lastIndex = 0;
|
||||
var meta = [];
|
||||
|
||||
anchors.forEach(function (anchor) {
|
||||
var text = anchor.textContent.trim();
|
||||
if (!text) {
|
||||
return;
|
||||
}
|
||||
|
||||
var href = anchor.getAttribute('href');
|
||||
var start = typeText.indexOf(text, lastIndex);
|
||||
|
||||
if (start === -1) {
|
||||
start = typeText.indexOf(text);
|
||||
if (start === -1) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
meta.push({
|
||||
start: start,
|
||||
end: start + text.length,
|
||||
href: href
|
||||
});
|
||||
|
||||
lastIndex = start + text.length;
|
||||
});
|
||||
|
||||
return meta;
|
||||
}
|
||||
|
||||
function restoreLinks(codeElement, meta) {
|
||||
var sorted = meta.slice().sort(function (a, b) {
|
||||
return b.start - a.start;
|
||||
});
|
||||
|
||||
sorted.forEach(function (info) {
|
||||
var startPos = findTextPosition(codeElement, info.start);
|
||||
var endPos = findTextPosition(codeElement, info.end);
|
||||
|
||||
if (!startPos || !endPos) {
|
||||
return;
|
||||
}
|
||||
|
||||
var range = document.createRange();
|
||||
range.setStart(startPos.node, startPos.offset);
|
||||
range.setEnd(endPos.node, endPos.offset);
|
||||
|
||||
var anchor = document.createElement('a');
|
||||
anchor.setAttribute('href', info.href);
|
||||
anchor.appendChild(range.extractContents());
|
||||
range.insertNode(anchor);
|
||||
range.detach();
|
||||
});
|
||||
}
|
||||
|
||||
function findTextPosition(container, targetIndex) {
|
||||
var walker = document.createTreeWalker(
|
||||
container,
|
||||
NodeFilter.SHOW_TEXT,
|
||||
null
|
||||
);
|
||||
|
||||
var currentIndex = 0;
|
||||
var currentNode;
|
||||
|
||||
while ((currentNode = walker.nextNode())) {
|
||||
var nextIndex = currentIndex + currentNode.textContent.length;
|
||||
|
||||
if (targetIndex <= nextIndex) {
|
||||
return {
|
||||
node: currentNode,
|
||||
offset: targetIndex - currentIndex
|
||||
};
|
||||
}
|
||||
|
||||
currentIndex = nextIndex;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -321,15 +503,17 @@
|
||||
</table>
|
||||
|
||||
|
||||
<h4>Return Value</h4>
|
||||
<h4 class="return-value-header">Return Value</h4>
|
||||
|
||||
<table class="table table-condensed">
|
||||
<div class="return-value-content">
|
||||
<table class="table table-condensed">
|
||||
<tr>
|
||||
<td>bool|<a href="RedisSentinel.html">RedisSentinel</a></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
@@ -363,15 +547,17 @@
|
||||
</table>
|
||||
|
||||
|
||||
<h4>Return Value</h4>
|
||||
<h4 class="return-value-header">Return Value</h4>
|
||||
|
||||
<table class="table table-condensed">
|
||||
<div class="return-value-content">
|
||||
<table class="table table-condensed">
|
||||
<tr>
|
||||
<td>bool|<a href="RedisSentinel.html">RedisSentinel</a></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
@@ -395,15 +581,17 @@
|
||||
</div>
|
||||
<div class="tags">
|
||||
|
||||
<h4>Return Value</h4>
|
||||
<h4 class="return-value-header">Return Value</h4>
|
||||
|
||||
<table class="table table-condensed">
|
||||
<div class="return-value-content">
|
||||
<table class="table table-condensed">
|
||||
<tr>
|
||||
<td>bool|<a href="RedisSentinel.html">RedisSentinel</a></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
@@ -437,15 +625,17 @@
|
||||
</table>
|
||||
|
||||
|
||||
<h4>Return Value</h4>
|
||||
<h4 class="return-value-header">Return Value</h4>
|
||||
|
||||
<table class="table table-condensed">
|
||||
<div class="return-value-content">
|
||||
<table class="table table-condensed">
|
||||
<tr>
|
||||
<td>array|bool|<a href="RedisSentinel.html">RedisSentinel</a></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
@@ -479,15 +669,17 @@
|
||||
</table>
|
||||
|
||||
|
||||
<h4>Return Value</h4>
|
||||
<h4 class="return-value-header">Return Value</h4>
|
||||
|
||||
<table class="table table-condensed">
|
||||
<div class="return-value-content">
|
||||
<table class="table table-condensed">
|
||||
<tr>
|
||||
<td>array|bool|<a href="RedisSentinel.html">RedisSentinel</a></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
@@ -511,15 +703,17 @@
|
||||
</div>
|
||||
<div class="tags">
|
||||
|
||||
<h4>Return Value</h4>
|
||||
<h4 class="return-value-header">Return Value</h4>
|
||||
|
||||
<table class="table table-condensed">
|
||||
<div class="return-value-content">
|
||||
<table class="table table-condensed">
|
||||
<tr>
|
||||
<td>array|bool|<a href="RedisSentinel.html">RedisSentinel</a></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
@@ -543,15 +737,17 @@
|
||||
</div>
|
||||
<div class="tags">
|
||||
|
||||
<h4>Return Value</h4>
|
||||
<h4 class="return-value-header">Return Value</h4>
|
||||
|
||||
<table class="table table-condensed">
|
||||
<div class="return-value-content">
|
||||
<table class="table table-condensed">
|
||||
<tr>
|
||||
<td>string</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
@@ -575,15 +771,17 @@
|
||||
</div>
|
||||
<div class="tags">
|
||||
|
||||
<h4>Return Value</h4>
|
||||
<h4 class="return-value-header">Return Value</h4>
|
||||
|
||||
<table class="table table-condensed">
|
||||
<div class="return-value-content">
|
||||
<table class="table table-condensed">
|
||||
<tr>
|
||||
<td>bool|<a href="RedisSentinel.html">RedisSentinel</a></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
@@ -617,15 +815,17 @@
|
||||
</table>
|
||||
|
||||
|
||||
<h4>Return Value</h4>
|
||||
<h4 class="return-value-header">Return Value</h4>
|
||||
|
||||
<table class="table table-condensed">
|
||||
<div class="return-value-content">
|
||||
<table class="table table-condensed">
|
||||
<tr>
|
||||
<td>int|<a href="RedisSentinel.html">RedisSentinel</a></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
@@ -659,15 +859,17 @@
|
||||
</table>
|
||||
|
||||
|
||||
<h4>Return Value</h4>
|
||||
<h4 class="return-value-header">Return Value</h4>
|
||||
|
||||
<table class="table table-condensed">
|
||||
<div class="return-value-content">
|
||||
<table class="table table-condensed">
|
||||
<tr>
|
||||
<td>array|bool|<a href="RedisSentinel.html">RedisSentinel</a></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
@@ -701,15 +903,17 @@
|
||||
</table>
|
||||
|
||||
|
||||
<h4>Return Value</h4>
|
||||
<h4 class="return-value-header">Return Value</h4>
|
||||
|
||||
<table class="table table-condensed">
|
||||
<div class="return-value-content">
|
||||
<table class="table table-condensed">
|
||||
<tr>
|
||||
<td>array|bool|<a href="RedisSentinel.html">RedisSentinel</a></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -24,6 +24,45 @@
|
||||
return;
|
||||
}
|
||||
|
||||
function ensureCustomClassesAreBuiltIn() {
|
||||
var classesToAdd = ['Redis', 'RedisCluster', 'RedisArray'];
|
||||
|
||||
if (!hljs.getLanguage) {
|
||||
return;
|
||||
}
|
||||
|
||||
var phpLanguage = hljs.getLanguage('php');
|
||||
if (!phpLanguage || !phpLanguage.keywords) {
|
||||
return;
|
||||
}
|
||||
|
||||
var builtIns = phpLanguage.keywords.built_in;
|
||||
if (!builtIns) {
|
||||
phpLanguage.keywords.built_in = classesToAdd.join(' ');
|
||||
return;
|
||||
}
|
||||
|
||||
if (Array.isArray(builtIns)) {
|
||||
classesToAdd.forEach(function (className) {
|
||||
if (builtIns.indexOf(className) === -1) {
|
||||
builtIns.push(className);
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (typeof builtIns === 'string') {
|
||||
classesToAdd.forEach(function (className) {
|
||||
if (builtIns.indexOf(className) === -1) {
|
||||
builtIns += ' ' + className;
|
||||
}
|
||||
});
|
||||
phpLanguage.keywords.built_in = builtIns;
|
||||
}
|
||||
}
|
||||
|
||||
ensureCustomClassesAreBuiltIn();
|
||||
|
||||
var exampleBlocks = document.querySelectorAll('pre.examples');
|
||||
exampleBlocks.forEach(function (block) {
|
||||
if (!block.dataset.language) {
|
||||
@@ -40,6 +79,149 @@
|
||||
}
|
||||
hljs.highlightElement(block);
|
||||
});
|
||||
|
||||
var phpCodeBlocks = document.querySelectorAll('pre code.language-php');
|
||||
phpCodeBlocks.forEach(function (block) {
|
||||
if (block.classList.contains('method-signature')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (block.closest('pre.examples')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (block.parentElement && !block.parentElement.classList.contains('language-php')) {
|
||||
block.parentElement.classList.add('language-php');
|
||||
}
|
||||
|
||||
hljs.highlightElement(block);
|
||||
});
|
||||
|
||||
highlightReturnTypes();
|
||||
|
||||
function highlightReturnTypes() {
|
||||
if (!document.createTreeWalker || !window.NodeFilter) {
|
||||
return;
|
||||
}
|
||||
|
||||
var containers = document.querySelectorAll('.return-value-content');
|
||||
containers.forEach(function (container) {
|
||||
var table = container.querySelector('table');
|
||||
if (!table) {
|
||||
return;
|
||||
}
|
||||
|
||||
table.querySelectorAll('tr').forEach(function (row) {
|
||||
var typeCell = row.querySelector('td');
|
||||
if (!typeCell || typeCell.querySelector('code.return-type')) {
|
||||
return;
|
||||
}
|
||||
|
||||
var typeText = typeCell.textContent.trim();
|
||||
if (!typeText) {
|
||||
return;
|
||||
}
|
||||
|
||||
var linkMeta = collectLinkMetadata(typeCell, typeText);
|
||||
var code = document.createElement('code');
|
||||
code.className = 'return-type language-php';
|
||||
code.textContent = typeText;
|
||||
|
||||
typeCell.innerHTML = '';
|
||||
typeCell.appendChild(code);
|
||||
|
||||
hljs.highlightElement(code);
|
||||
|
||||
if (linkMeta.length) {
|
||||
restoreLinks(code, linkMeta);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function collectLinkMetadata(cell, typeText) {
|
||||
var anchors = cell.querySelectorAll('a');
|
||||
var lastIndex = 0;
|
||||
var meta = [];
|
||||
|
||||
anchors.forEach(function (anchor) {
|
||||
var text = anchor.textContent.trim();
|
||||
if (!text) {
|
||||
return;
|
||||
}
|
||||
|
||||
var href = anchor.getAttribute('href');
|
||||
var start = typeText.indexOf(text, lastIndex);
|
||||
|
||||
if (start === -1) {
|
||||
start = typeText.indexOf(text);
|
||||
if (start === -1) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
meta.push({
|
||||
start: start,
|
||||
end: start + text.length,
|
||||
href: href
|
||||
});
|
||||
|
||||
lastIndex = start + text.length;
|
||||
});
|
||||
|
||||
return meta;
|
||||
}
|
||||
|
||||
function restoreLinks(codeElement, meta) {
|
||||
var sorted = meta.slice().sort(function (a, b) {
|
||||
return b.start - a.start;
|
||||
});
|
||||
|
||||
sorted.forEach(function (info) {
|
||||
var startPos = findTextPosition(codeElement, info.start);
|
||||
var endPos = findTextPosition(codeElement, info.end);
|
||||
|
||||
if (!startPos || !endPos) {
|
||||
return;
|
||||
}
|
||||
|
||||
var range = document.createRange();
|
||||
range.setStart(startPos.node, startPos.offset);
|
||||
range.setEnd(endPos.node, endPos.offset);
|
||||
|
||||
var anchor = document.createElement('a');
|
||||
anchor.setAttribute('href', info.href);
|
||||
anchor.appendChild(range.extractContents());
|
||||
range.insertNode(anchor);
|
||||
range.detach();
|
||||
});
|
||||
}
|
||||
|
||||
function findTextPosition(container, targetIndex) {
|
||||
var walker = document.createTreeWalker(
|
||||
container,
|
||||
NodeFilter.SHOW_TEXT,
|
||||
null
|
||||
);
|
||||
|
||||
var currentIndex = 0;
|
||||
var currentNode;
|
||||
|
||||
while ((currentNode = walker.nextNode())) {
|
||||
var nextIndex = currentIndex + currentNode.textContent.length;
|
||||
|
||||
if (targetIndex <= nextIndex) {
|
||||
return {
|
||||
node: currentNode,
|
||||
offset: targetIndex - currentIndex
|
||||
};
|
||||
}
|
||||
|
||||
currentIndex = nextIndex;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
@@ -24,6 +24,45 @@
|
||||
return;
|
||||
}
|
||||
|
||||
function ensureCustomClassesAreBuiltIn() {
|
||||
var classesToAdd = ['Redis', 'RedisCluster', 'RedisArray'];
|
||||
|
||||
if (!hljs.getLanguage) {
|
||||
return;
|
||||
}
|
||||
|
||||
var phpLanguage = hljs.getLanguage('php');
|
||||
if (!phpLanguage || !phpLanguage.keywords) {
|
||||
return;
|
||||
}
|
||||
|
||||
var builtIns = phpLanguage.keywords.built_in;
|
||||
if (!builtIns) {
|
||||
phpLanguage.keywords.built_in = classesToAdd.join(' ');
|
||||
return;
|
||||
}
|
||||
|
||||
if (Array.isArray(builtIns)) {
|
||||
classesToAdd.forEach(function (className) {
|
||||
if (builtIns.indexOf(className) === -1) {
|
||||
builtIns.push(className);
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (typeof builtIns === 'string') {
|
||||
classesToAdd.forEach(function (className) {
|
||||
if (builtIns.indexOf(className) === -1) {
|
||||
builtIns += ' ' + className;
|
||||
}
|
||||
});
|
||||
phpLanguage.keywords.built_in = builtIns;
|
||||
}
|
||||
}
|
||||
|
||||
ensureCustomClassesAreBuiltIn();
|
||||
|
||||
var exampleBlocks = document.querySelectorAll('pre.examples');
|
||||
exampleBlocks.forEach(function (block) {
|
||||
if (!block.dataset.language) {
|
||||
@@ -40,6 +79,149 @@
|
||||
}
|
||||
hljs.highlightElement(block);
|
||||
});
|
||||
|
||||
var phpCodeBlocks = document.querySelectorAll('pre code.language-php');
|
||||
phpCodeBlocks.forEach(function (block) {
|
||||
if (block.classList.contains('method-signature')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (block.closest('pre.examples')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (block.parentElement && !block.parentElement.classList.contains('language-php')) {
|
||||
block.parentElement.classList.add('language-php');
|
||||
}
|
||||
|
||||
hljs.highlightElement(block);
|
||||
});
|
||||
|
||||
highlightReturnTypes();
|
||||
|
||||
function highlightReturnTypes() {
|
||||
if (!document.createTreeWalker || !window.NodeFilter) {
|
||||
return;
|
||||
}
|
||||
|
||||
var containers = document.querySelectorAll('.return-value-content');
|
||||
containers.forEach(function (container) {
|
||||
var table = container.querySelector('table');
|
||||
if (!table) {
|
||||
return;
|
||||
}
|
||||
|
||||
table.querySelectorAll('tr').forEach(function (row) {
|
||||
var typeCell = row.querySelector('td');
|
||||
if (!typeCell || typeCell.querySelector('code.return-type')) {
|
||||
return;
|
||||
}
|
||||
|
||||
var typeText = typeCell.textContent.trim();
|
||||
if (!typeText) {
|
||||
return;
|
||||
}
|
||||
|
||||
var linkMeta = collectLinkMetadata(typeCell, typeText);
|
||||
var code = document.createElement('code');
|
||||
code.className = 'return-type language-php';
|
||||
code.textContent = typeText;
|
||||
|
||||
typeCell.innerHTML = '';
|
||||
typeCell.appendChild(code);
|
||||
|
||||
hljs.highlightElement(code);
|
||||
|
||||
if (linkMeta.length) {
|
||||
restoreLinks(code, linkMeta);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function collectLinkMetadata(cell, typeText) {
|
||||
var anchors = cell.querySelectorAll('a');
|
||||
var lastIndex = 0;
|
||||
var meta = [];
|
||||
|
||||
anchors.forEach(function (anchor) {
|
||||
var text = anchor.textContent.trim();
|
||||
if (!text) {
|
||||
return;
|
||||
}
|
||||
|
||||
var href = anchor.getAttribute('href');
|
||||
var start = typeText.indexOf(text, lastIndex);
|
||||
|
||||
if (start === -1) {
|
||||
start = typeText.indexOf(text);
|
||||
if (start === -1) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
meta.push({
|
||||
start: start,
|
||||
end: start + text.length,
|
||||
href: href
|
||||
});
|
||||
|
||||
lastIndex = start + text.length;
|
||||
});
|
||||
|
||||
return meta;
|
||||
}
|
||||
|
||||
function restoreLinks(codeElement, meta) {
|
||||
var sorted = meta.slice().sort(function (a, b) {
|
||||
return b.start - a.start;
|
||||
});
|
||||
|
||||
sorted.forEach(function (info) {
|
||||
var startPos = findTextPosition(codeElement, info.start);
|
||||
var endPos = findTextPosition(codeElement, info.end);
|
||||
|
||||
if (!startPos || !endPos) {
|
||||
return;
|
||||
}
|
||||
|
||||
var range = document.createRange();
|
||||
range.setStart(startPos.node, startPos.offset);
|
||||
range.setEnd(endPos.node, endPos.offset);
|
||||
|
||||
var anchor = document.createElement('a');
|
||||
anchor.setAttribute('href', info.href);
|
||||
anchor.appendChild(range.extractContents());
|
||||
range.insertNode(anchor);
|
||||
range.detach();
|
||||
});
|
||||
}
|
||||
|
||||
function findTextPosition(container, targetIndex) {
|
||||
var walker = document.createTreeWalker(
|
||||
container,
|
||||
NodeFilter.SHOW_TEXT,
|
||||
null
|
||||
);
|
||||
|
||||
var currentIndex = 0;
|
||||
var currentNode;
|
||||
|
||||
while ((currentNode = walker.nextNode())) {
|
||||
var nextIndex = currentIndex + currentNode.textContent.length;
|
||||
|
||||
if (targetIndex <= nextIndex) {
|
||||
return {
|
||||
node: currentNode,
|
||||
offset: targetIndex - currentIndex
|
||||
};
|
||||
}
|
||||
|
||||
currentIndex = nextIndex;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
@@ -24,6 +24,45 @@
|
||||
return;
|
||||
}
|
||||
|
||||
function ensureCustomClassesAreBuiltIn() {
|
||||
var classesToAdd = ['Redis', 'RedisCluster', 'RedisArray'];
|
||||
|
||||
if (!hljs.getLanguage) {
|
||||
return;
|
||||
}
|
||||
|
||||
var phpLanguage = hljs.getLanguage('php');
|
||||
if (!phpLanguage || !phpLanguage.keywords) {
|
||||
return;
|
||||
}
|
||||
|
||||
var builtIns = phpLanguage.keywords.built_in;
|
||||
if (!builtIns) {
|
||||
phpLanguage.keywords.built_in = classesToAdd.join(' ');
|
||||
return;
|
||||
}
|
||||
|
||||
if (Array.isArray(builtIns)) {
|
||||
classesToAdd.forEach(function (className) {
|
||||
if (builtIns.indexOf(className) === -1) {
|
||||
builtIns.push(className);
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (typeof builtIns === 'string') {
|
||||
classesToAdd.forEach(function (className) {
|
||||
if (builtIns.indexOf(className) === -1) {
|
||||
builtIns += ' ' + className;
|
||||
}
|
||||
});
|
||||
phpLanguage.keywords.built_in = builtIns;
|
||||
}
|
||||
}
|
||||
|
||||
ensureCustomClassesAreBuiltIn();
|
||||
|
||||
var exampleBlocks = document.querySelectorAll('pre.examples');
|
||||
exampleBlocks.forEach(function (block) {
|
||||
if (!block.dataset.language) {
|
||||
@@ -40,6 +79,149 @@
|
||||
}
|
||||
hljs.highlightElement(block);
|
||||
});
|
||||
|
||||
var phpCodeBlocks = document.querySelectorAll('pre code.language-php');
|
||||
phpCodeBlocks.forEach(function (block) {
|
||||
if (block.classList.contains('method-signature')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (block.closest('pre.examples')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (block.parentElement && !block.parentElement.classList.contains('language-php')) {
|
||||
block.parentElement.classList.add('language-php');
|
||||
}
|
||||
|
||||
hljs.highlightElement(block);
|
||||
});
|
||||
|
||||
highlightReturnTypes();
|
||||
|
||||
function highlightReturnTypes() {
|
||||
if (!document.createTreeWalker || !window.NodeFilter) {
|
||||
return;
|
||||
}
|
||||
|
||||
var containers = document.querySelectorAll('.return-value-content');
|
||||
containers.forEach(function (container) {
|
||||
var table = container.querySelector('table');
|
||||
if (!table) {
|
||||
return;
|
||||
}
|
||||
|
||||
table.querySelectorAll('tr').forEach(function (row) {
|
||||
var typeCell = row.querySelector('td');
|
||||
if (!typeCell || typeCell.querySelector('code.return-type')) {
|
||||
return;
|
||||
}
|
||||
|
||||
var typeText = typeCell.textContent.trim();
|
||||
if (!typeText) {
|
||||
return;
|
||||
}
|
||||
|
||||
var linkMeta = collectLinkMetadata(typeCell, typeText);
|
||||
var code = document.createElement('code');
|
||||
code.className = 'return-type language-php';
|
||||
code.textContent = typeText;
|
||||
|
||||
typeCell.innerHTML = '';
|
||||
typeCell.appendChild(code);
|
||||
|
||||
hljs.highlightElement(code);
|
||||
|
||||
if (linkMeta.length) {
|
||||
restoreLinks(code, linkMeta);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function collectLinkMetadata(cell, typeText) {
|
||||
var anchors = cell.querySelectorAll('a');
|
||||
var lastIndex = 0;
|
||||
var meta = [];
|
||||
|
||||
anchors.forEach(function (anchor) {
|
||||
var text = anchor.textContent.trim();
|
||||
if (!text) {
|
||||
return;
|
||||
}
|
||||
|
||||
var href = anchor.getAttribute('href');
|
||||
var start = typeText.indexOf(text, lastIndex);
|
||||
|
||||
if (start === -1) {
|
||||
start = typeText.indexOf(text);
|
||||
if (start === -1) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
meta.push({
|
||||
start: start,
|
||||
end: start + text.length,
|
||||
href: href
|
||||
});
|
||||
|
||||
lastIndex = start + text.length;
|
||||
});
|
||||
|
||||
return meta;
|
||||
}
|
||||
|
||||
function restoreLinks(codeElement, meta) {
|
||||
var sorted = meta.slice().sort(function (a, b) {
|
||||
return b.start - a.start;
|
||||
});
|
||||
|
||||
sorted.forEach(function (info) {
|
||||
var startPos = findTextPosition(codeElement, info.start);
|
||||
var endPos = findTextPosition(codeElement, info.end);
|
||||
|
||||
if (!startPos || !endPos) {
|
||||
return;
|
||||
}
|
||||
|
||||
var range = document.createRange();
|
||||
range.setStart(startPos.node, startPos.offset);
|
||||
range.setEnd(endPos.node, endPos.offset);
|
||||
|
||||
var anchor = document.createElement('a');
|
||||
anchor.setAttribute('href', info.href);
|
||||
anchor.appendChild(range.extractContents());
|
||||
range.insertNode(anchor);
|
||||
range.detach();
|
||||
});
|
||||
}
|
||||
|
||||
function findTextPosition(container, targetIndex) {
|
||||
var walker = document.createTreeWalker(
|
||||
container,
|
||||
NodeFilter.SHOW_TEXT,
|
||||
null
|
||||
);
|
||||
|
||||
var currentIndex = 0;
|
||||
var currentNode;
|
||||
|
||||
while ((currentNode = walker.nextNode())) {
|
||||
var nextIndex = currentIndex + currentNode.textContent.length;
|
||||
|
||||
if (targetIndex <= nextIndex) {
|
||||
return {
|
||||
node: currentNode,
|
||||
offset: targetIndex - currentIndex
|
||||
};
|
||||
}
|
||||
|
||||
currentIndex = nextIndex;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
+182
@@ -24,6 +24,45 @@
|
||||
return;
|
||||
}
|
||||
|
||||
function ensureCustomClassesAreBuiltIn() {
|
||||
var classesToAdd = ['Redis', 'RedisCluster', 'RedisArray'];
|
||||
|
||||
if (!hljs.getLanguage) {
|
||||
return;
|
||||
}
|
||||
|
||||
var phpLanguage = hljs.getLanguage('php');
|
||||
if (!phpLanguage || !phpLanguage.keywords) {
|
||||
return;
|
||||
}
|
||||
|
||||
var builtIns = phpLanguage.keywords.built_in;
|
||||
if (!builtIns) {
|
||||
phpLanguage.keywords.built_in = classesToAdd.join(' ');
|
||||
return;
|
||||
}
|
||||
|
||||
if (Array.isArray(builtIns)) {
|
||||
classesToAdd.forEach(function (className) {
|
||||
if (builtIns.indexOf(className) === -1) {
|
||||
builtIns.push(className);
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (typeof builtIns === 'string') {
|
||||
classesToAdd.forEach(function (className) {
|
||||
if (builtIns.indexOf(className) === -1) {
|
||||
builtIns += ' ' + className;
|
||||
}
|
||||
});
|
||||
phpLanguage.keywords.built_in = builtIns;
|
||||
}
|
||||
}
|
||||
|
||||
ensureCustomClassesAreBuiltIn();
|
||||
|
||||
var exampleBlocks = document.querySelectorAll('pre.examples');
|
||||
exampleBlocks.forEach(function (block) {
|
||||
if (!block.dataset.language) {
|
||||
@@ -40,6 +79,149 @@
|
||||
}
|
||||
hljs.highlightElement(block);
|
||||
});
|
||||
|
||||
var phpCodeBlocks = document.querySelectorAll('pre code.language-php');
|
||||
phpCodeBlocks.forEach(function (block) {
|
||||
if (block.classList.contains('method-signature')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (block.closest('pre.examples')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (block.parentElement && !block.parentElement.classList.contains('language-php')) {
|
||||
block.parentElement.classList.add('language-php');
|
||||
}
|
||||
|
||||
hljs.highlightElement(block);
|
||||
});
|
||||
|
||||
highlightReturnTypes();
|
||||
|
||||
function highlightReturnTypes() {
|
||||
if (!document.createTreeWalker || !window.NodeFilter) {
|
||||
return;
|
||||
}
|
||||
|
||||
var containers = document.querySelectorAll('.return-value-content');
|
||||
containers.forEach(function (container) {
|
||||
var table = container.querySelector('table');
|
||||
if (!table) {
|
||||
return;
|
||||
}
|
||||
|
||||
table.querySelectorAll('tr').forEach(function (row) {
|
||||
var typeCell = row.querySelector('td');
|
||||
if (!typeCell || typeCell.querySelector('code.return-type')) {
|
||||
return;
|
||||
}
|
||||
|
||||
var typeText = typeCell.textContent.trim();
|
||||
if (!typeText) {
|
||||
return;
|
||||
}
|
||||
|
||||
var linkMeta = collectLinkMetadata(typeCell, typeText);
|
||||
var code = document.createElement('code');
|
||||
code.className = 'return-type language-php';
|
||||
code.textContent = typeText;
|
||||
|
||||
typeCell.innerHTML = '';
|
||||
typeCell.appendChild(code);
|
||||
|
||||
hljs.highlightElement(code);
|
||||
|
||||
if (linkMeta.length) {
|
||||
restoreLinks(code, linkMeta);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function collectLinkMetadata(cell, typeText) {
|
||||
var anchors = cell.querySelectorAll('a');
|
||||
var lastIndex = 0;
|
||||
var meta = [];
|
||||
|
||||
anchors.forEach(function (anchor) {
|
||||
var text = anchor.textContent.trim();
|
||||
if (!text) {
|
||||
return;
|
||||
}
|
||||
|
||||
var href = anchor.getAttribute('href');
|
||||
var start = typeText.indexOf(text, lastIndex);
|
||||
|
||||
if (start === -1) {
|
||||
start = typeText.indexOf(text);
|
||||
if (start === -1) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
meta.push({
|
||||
start: start,
|
||||
end: start + text.length,
|
||||
href: href
|
||||
});
|
||||
|
||||
lastIndex = start + text.length;
|
||||
});
|
||||
|
||||
return meta;
|
||||
}
|
||||
|
||||
function restoreLinks(codeElement, meta) {
|
||||
var sorted = meta.slice().sort(function (a, b) {
|
||||
return b.start - a.start;
|
||||
});
|
||||
|
||||
sorted.forEach(function (info) {
|
||||
var startPos = findTextPosition(codeElement, info.start);
|
||||
var endPos = findTextPosition(codeElement, info.end);
|
||||
|
||||
if (!startPos || !endPos) {
|
||||
return;
|
||||
}
|
||||
|
||||
var range = document.createRange();
|
||||
range.setStart(startPos.node, startPos.offset);
|
||||
range.setEnd(endPos.node, endPos.offset);
|
||||
|
||||
var anchor = document.createElement('a');
|
||||
anchor.setAttribute('href', info.href);
|
||||
anchor.appendChild(range.extractContents());
|
||||
range.insertNode(anchor);
|
||||
range.detach();
|
||||
});
|
||||
}
|
||||
|
||||
function findTextPosition(container, targetIndex) {
|
||||
var walker = document.createTreeWalker(
|
||||
container,
|
||||
NodeFilter.SHOW_TEXT,
|
||||
null
|
||||
);
|
||||
|
||||
var currentIndex = 0;
|
||||
var currentNode;
|
||||
|
||||
while ((currentNode = walker.nextNode())) {
|
||||
var nextIndex = currentIndex + currentNode.textContent.length;
|
||||
|
||||
if (targetIndex <= nextIndex) {
|
||||
return {
|
||||
node: currentNode,
|
||||
offset: targetIndex - currentIndex
|
||||
};
|
||||
}
|
||||
|
||||
currentIndex = nextIndex;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
@@ -24,6 +24,45 @@
|
||||
return;
|
||||
}
|
||||
|
||||
function ensureCustomClassesAreBuiltIn() {
|
||||
var classesToAdd = ['Redis', 'RedisCluster', 'RedisArray'];
|
||||
|
||||
if (!hljs.getLanguage) {
|
||||
return;
|
||||
}
|
||||
|
||||
var phpLanguage = hljs.getLanguage('php');
|
||||
if (!phpLanguage || !phpLanguage.keywords) {
|
||||
return;
|
||||
}
|
||||
|
||||
var builtIns = phpLanguage.keywords.built_in;
|
||||
if (!builtIns) {
|
||||
phpLanguage.keywords.built_in = classesToAdd.join(' ');
|
||||
return;
|
||||
}
|
||||
|
||||
if (Array.isArray(builtIns)) {
|
||||
classesToAdd.forEach(function (className) {
|
||||
if (builtIns.indexOf(className) === -1) {
|
||||
builtIns.push(className);
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (typeof builtIns === 'string') {
|
||||
classesToAdd.forEach(function (className) {
|
||||
if (builtIns.indexOf(className) === -1) {
|
||||
builtIns += ' ' + className;
|
||||
}
|
||||
});
|
||||
phpLanguage.keywords.built_in = builtIns;
|
||||
}
|
||||
}
|
||||
|
||||
ensureCustomClassesAreBuiltIn();
|
||||
|
||||
var exampleBlocks = document.querySelectorAll('pre.examples');
|
||||
exampleBlocks.forEach(function (block) {
|
||||
if (!block.dataset.language) {
|
||||
@@ -40,6 +79,149 @@
|
||||
}
|
||||
hljs.highlightElement(block);
|
||||
});
|
||||
|
||||
var phpCodeBlocks = document.querySelectorAll('pre code.language-php');
|
||||
phpCodeBlocks.forEach(function (block) {
|
||||
if (block.classList.contains('method-signature')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (block.closest('pre.examples')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (block.parentElement && !block.parentElement.classList.contains('language-php')) {
|
||||
block.parentElement.classList.add('language-php');
|
||||
}
|
||||
|
||||
hljs.highlightElement(block);
|
||||
});
|
||||
|
||||
highlightReturnTypes();
|
||||
|
||||
function highlightReturnTypes() {
|
||||
if (!document.createTreeWalker || !window.NodeFilter) {
|
||||
return;
|
||||
}
|
||||
|
||||
var containers = document.querySelectorAll('.return-value-content');
|
||||
containers.forEach(function (container) {
|
||||
var table = container.querySelector('table');
|
||||
if (!table) {
|
||||
return;
|
||||
}
|
||||
|
||||
table.querySelectorAll('tr').forEach(function (row) {
|
||||
var typeCell = row.querySelector('td');
|
||||
if (!typeCell || typeCell.querySelector('code.return-type')) {
|
||||
return;
|
||||
}
|
||||
|
||||
var typeText = typeCell.textContent.trim();
|
||||
if (!typeText) {
|
||||
return;
|
||||
}
|
||||
|
||||
var linkMeta = collectLinkMetadata(typeCell, typeText);
|
||||
var code = document.createElement('code');
|
||||
code.className = 'return-type language-php';
|
||||
code.textContent = typeText;
|
||||
|
||||
typeCell.innerHTML = '';
|
||||
typeCell.appendChild(code);
|
||||
|
||||
hljs.highlightElement(code);
|
||||
|
||||
if (linkMeta.length) {
|
||||
restoreLinks(code, linkMeta);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function collectLinkMetadata(cell, typeText) {
|
||||
var anchors = cell.querySelectorAll('a');
|
||||
var lastIndex = 0;
|
||||
var meta = [];
|
||||
|
||||
anchors.forEach(function (anchor) {
|
||||
var text = anchor.textContent.trim();
|
||||
if (!text) {
|
||||
return;
|
||||
}
|
||||
|
||||
var href = anchor.getAttribute('href');
|
||||
var start = typeText.indexOf(text, lastIndex);
|
||||
|
||||
if (start === -1) {
|
||||
start = typeText.indexOf(text);
|
||||
if (start === -1) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
meta.push({
|
||||
start: start,
|
||||
end: start + text.length,
|
||||
href: href
|
||||
});
|
||||
|
||||
lastIndex = start + text.length;
|
||||
});
|
||||
|
||||
return meta;
|
||||
}
|
||||
|
||||
function restoreLinks(codeElement, meta) {
|
||||
var sorted = meta.slice().sort(function (a, b) {
|
||||
return b.start - a.start;
|
||||
});
|
||||
|
||||
sorted.forEach(function (info) {
|
||||
var startPos = findTextPosition(codeElement, info.start);
|
||||
var endPos = findTextPosition(codeElement, info.end);
|
||||
|
||||
if (!startPos || !endPos) {
|
||||
return;
|
||||
}
|
||||
|
||||
var range = document.createRange();
|
||||
range.setStart(startPos.node, startPos.offset);
|
||||
range.setEnd(endPos.node, endPos.offset);
|
||||
|
||||
var anchor = document.createElement('a');
|
||||
anchor.setAttribute('href', info.href);
|
||||
anchor.appendChild(range.extractContents());
|
||||
range.insertNode(anchor);
|
||||
range.detach();
|
||||
});
|
||||
}
|
||||
|
||||
function findTextPosition(container, targetIndex) {
|
||||
var walker = document.createTreeWalker(
|
||||
container,
|
||||
NodeFilter.SHOW_TEXT,
|
||||
null
|
||||
);
|
||||
|
||||
var currentIndex = 0;
|
||||
var currentNode;
|
||||
|
||||
while ((currentNode = walker.nextNode())) {
|
||||
var nextIndex = currentIndex + currentNode.textContent.length;
|
||||
|
||||
if (targetIndex <= nextIndex) {
|
||||
return {
|
||||
node: currentNode,
|
||||
offset: targetIndex - currentIndex
|
||||
};
|
||||
}
|
||||
|
||||
currentIndex = nextIndex;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
@@ -24,6 +24,45 @@
|
||||
return;
|
||||
}
|
||||
|
||||
function ensureCustomClassesAreBuiltIn() {
|
||||
var classesToAdd = ['Redis', 'RedisCluster', 'RedisArray'];
|
||||
|
||||
if (!hljs.getLanguage) {
|
||||
return;
|
||||
}
|
||||
|
||||
var phpLanguage = hljs.getLanguage('php');
|
||||
if (!phpLanguage || !phpLanguage.keywords) {
|
||||
return;
|
||||
}
|
||||
|
||||
var builtIns = phpLanguage.keywords.built_in;
|
||||
if (!builtIns) {
|
||||
phpLanguage.keywords.built_in = classesToAdd.join(' ');
|
||||
return;
|
||||
}
|
||||
|
||||
if (Array.isArray(builtIns)) {
|
||||
classesToAdd.forEach(function (className) {
|
||||
if (builtIns.indexOf(className) === -1) {
|
||||
builtIns.push(className);
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (typeof builtIns === 'string') {
|
||||
classesToAdd.forEach(function (className) {
|
||||
if (builtIns.indexOf(className) === -1) {
|
||||
builtIns += ' ' + className;
|
||||
}
|
||||
});
|
||||
phpLanguage.keywords.built_in = builtIns;
|
||||
}
|
||||
}
|
||||
|
||||
ensureCustomClassesAreBuiltIn();
|
||||
|
||||
var exampleBlocks = document.querySelectorAll('pre.examples');
|
||||
exampleBlocks.forEach(function (block) {
|
||||
if (!block.dataset.language) {
|
||||
@@ -40,6 +79,149 @@
|
||||
}
|
||||
hljs.highlightElement(block);
|
||||
});
|
||||
|
||||
var phpCodeBlocks = document.querySelectorAll('pre code.language-php');
|
||||
phpCodeBlocks.forEach(function (block) {
|
||||
if (block.classList.contains('method-signature')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (block.closest('pre.examples')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (block.parentElement && !block.parentElement.classList.contains('language-php')) {
|
||||
block.parentElement.classList.add('language-php');
|
||||
}
|
||||
|
||||
hljs.highlightElement(block);
|
||||
});
|
||||
|
||||
highlightReturnTypes();
|
||||
|
||||
function highlightReturnTypes() {
|
||||
if (!document.createTreeWalker || !window.NodeFilter) {
|
||||
return;
|
||||
}
|
||||
|
||||
var containers = document.querySelectorAll('.return-value-content');
|
||||
containers.forEach(function (container) {
|
||||
var table = container.querySelector('table');
|
||||
if (!table) {
|
||||
return;
|
||||
}
|
||||
|
||||
table.querySelectorAll('tr').forEach(function (row) {
|
||||
var typeCell = row.querySelector('td');
|
||||
if (!typeCell || typeCell.querySelector('code.return-type')) {
|
||||
return;
|
||||
}
|
||||
|
||||
var typeText = typeCell.textContent.trim();
|
||||
if (!typeText) {
|
||||
return;
|
||||
}
|
||||
|
||||
var linkMeta = collectLinkMetadata(typeCell, typeText);
|
||||
var code = document.createElement('code');
|
||||
code.className = 'return-type language-php';
|
||||
code.textContent = typeText;
|
||||
|
||||
typeCell.innerHTML = '';
|
||||
typeCell.appendChild(code);
|
||||
|
||||
hljs.highlightElement(code);
|
||||
|
||||
if (linkMeta.length) {
|
||||
restoreLinks(code, linkMeta);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function collectLinkMetadata(cell, typeText) {
|
||||
var anchors = cell.querySelectorAll('a');
|
||||
var lastIndex = 0;
|
||||
var meta = [];
|
||||
|
||||
anchors.forEach(function (anchor) {
|
||||
var text = anchor.textContent.trim();
|
||||
if (!text) {
|
||||
return;
|
||||
}
|
||||
|
||||
var href = anchor.getAttribute('href');
|
||||
var start = typeText.indexOf(text, lastIndex);
|
||||
|
||||
if (start === -1) {
|
||||
start = typeText.indexOf(text);
|
||||
if (start === -1) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
meta.push({
|
||||
start: start,
|
||||
end: start + text.length,
|
||||
href: href
|
||||
});
|
||||
|
||||
lastIndex = start + text.length;
|
||||
});
|
||||
|
||||
return meta;
|
||||
}
|
||||
|
||||
function restoreLinks(codeElement, meta) {
|
||||
var sorted = meta.slice().sort(function (a, b) {
|
||||
return b.start - a.start;
|
||||
});
|
||||
|
||||
sorted.forEach(function (info) {
|
||||
var startPos = findTextPosition(codeElement, info.start);
|
||||
var endPos = findTextPosition(codeElement, info.end);
|
||||
|
||||
if (!startPos || !endPos) {
|
||||
return;
|
||||
}
|
||||
|
||||
var range = document.createRange();
|
||||
range.setStart(startPos.node, startPos.offset);
|
||||
range.setEnd(endPos.node, endPos.offset);
|
||||
|
||||
var anchor = document.createElement('a');
|
||||
anchor.setAttribute('href', info.href);
|
||||
anchor.appendChild(range.extractContents());
|
||||
range.insertNode(anchor);
|
||||
range.detach();
|
||||
});
|
||||
}
|
||||
|
||||
function findTextPosition(container, targetIndex) {
|
||||
var walker = document.createTreeWalker(
|
||||
container,
|
||||
NodeFilter.SHOW_TEXT,
|
||||
null
|
||||
);
|
||||
|
||||
var currentIndex = 0;
|
||||
var currentNode;
|
||||
|
||||
while ((currentNode = walker.nextNode())) {
|
||||
var nextIndex = currentIndex + currentNode.textContent.length;
|
||||
|
||||
if (targetIndex <= nextIndex) {
|
||||
return {
|
||||
node: currentNode,
|
||||
offset: targetIndex - currentIndex
|
||||
};
|
||||
}
|
||||
|
||||
currentIndex = nextIndex;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
O:21:"Doctum\Renderer\Index":3:{i:0;a:6:{s:5:"Redis";s:40:"3fb167a9fc3728af414f3e091c4d4e98c73b0bec";s:10:"RedisArray";s:40:"2a50f02b4f62d96a18ec122fec35bd6e03bf735a";s:12:"RedisCluster";s:40:"76e57d541155478d414e8cfe84d56f6d07ec6e3d";s:21:"RedisClusterException";s:40:"76e57d541155478d414e8cfe84d56f6d07ec6e3d";s:14:"RedisException";s:40:"3fb167a9fc3728af414f3e091c4d4e98c73b0bec";s:13:"RedisSentinel";s:40:"ca40579af888c5bb0661cd0201d840297474479a";}i:1;a:1:{i:0;s:4:"main";}i:2;a:1:{i:0;s:0:"";}}
|
||||
O:21:"Doctum\Renderer\Index":3:{i:0;a:6:{s:5:"Redis";s:40:"0f4017b46063c1e1662b4d540387772581a1e9e6";s:10:"RedisArray";s:40:"2a50f02b4f62d96a18ec122fec35bd6e03bf735a";s:12:"RedisCluster";s:40:"76e57d541155478d414e8cfe84d56f6d07ec6e3d";s:21:"RedisClusterException";s:40:"76e57d541155478d414e8cfe84d56f6d07ec6e3d";s:14:"RedisException";s:40:"0f4017b46063c1e1662b4d540387772581a1e9e6";s:13:"RedisSentinel";s:40:"ca40579af888c5bb0661cd0201d840297474479a";}i:1;a:1:{i:0;s:4:"main";}i:2;a:1:{i:0;s:0:"";}}
|
||||
@@ -24,6 +24,45 @@
|
||||
return;
|
||||
}
|
||||
|
||||
function ensureCustomClassesAreBuiltIn() {
|
||||
var classesToAdd = ['Redis', 'RedisCluster', 'RedisArray'];
|
||||
|
||||
if (!hljs.getLanguage) {
|
||||
return;
|
||||
}
|
||||
|
||||
var phpLanguage = hljs.getLanguage('php');
|
||||
if (!phpLanguage || !phpLanguage.keywords) {
|
||||
return;
|
||||
}
|
||||
|
||||
var builtIns = phpLanguage.keywords.built_in;
|
||||
if (!builtIns) {
|
||||
phpLanguage.keywords.built_in = classesToAdd.join(' ');
|
||||
return;
|
||||
}
|
||||
|
||||
if (Array.isArray(builtIns)) {
|
||||
classesToAdd.forEach(function (className) {
|
||||
if (builtIns.indexOf(className) === -1) {
|
||||
builtIns.push(className);
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (typeof builtIns === 'string') {
|
||||
classesToAdd.forEach(function (className) {
|
||||
if (builtIns.indexOf(className) === -1) {
|
||||
builtIns += ' ' + className;
|
||||
}
|
||||
});
|
||||
phpLanguage.keywords.built_in = builtIns;
|
||||
}
|
||||
}
|
||||
|
||||
ensureCustomClassesAreBuiltIn();
|
||||
|
||||
var exampleBlocks = document.querySelectorAll('pre.examples');
|
||||
exampleBlocks.forEach(function (block) {
|
||||
if (!block.dataset.language) {
|
||||
@@ -40,6 +79,149 @@
|
||||
}
|
||||
hljs.highlightElement(block);
|
||||
});
|
||||
|
||||
var phpCodeBlocks = document.querySelectorAll('pre code.language-php');
|
||||
phpCodeBlocks.forEach(function (block) {
|
||||
if (block.classList.contains('method-signature')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (block.closest('pre.examples')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (block.parentElement && !block.parentElement.classList.contains('language-php')) {
|
||||
block.parentElement.classList.add('language-php');
|
||||
}
|
||||
|
||||
hljs.highlightElement(block);
|
||||
});
|
||||
|
||||
highlightReturnTypes();
|
||||
|
||||
function highlightReturnTypes() {
|
||||
if (!document.createTreeWalker || !window.NodeFilter) {
|
||||
return;
|
||||
}
|
||||
|
||||
var containers = document.querySelectorAll('.return-value-content');
|
||||
containers.forEach(function (container) {
|
||||
var table = container.querySelector('table');
|
||||
if (!table) {
|
||||
return;
|
||||
}
|
||||
|
||||
table.querySelectorAll('tr').forEach(function (row) {
|
||||
var typeCell = row.querySelector('td');
|
||||
if (!typeCell || typeCell.querySelector('code.return-type')) {
|
||||
return;
|
||||
}
|
||||
|
||||
var typeText = typeCell.textContent.trim();
|
||||
if (!typeText) {
|
||||
return;
|
||||
}
|
||||
|
||||
var linkMeta = collectLinkMetadata(typeCell, typeText);
|
||||
var code = document.createElement('code');
|
||||
code.className = 'return-type language-php';
|
||||
code.textContent = typeText;
|
||||
|
||||
typeCell.innerHTML = '';
|
||||
typeCell.appendChild(code);
|
||||
|
||||
hljs.highlightElement(code);
|
||||
|
||||
if (linkMeta.length) {
|
||||
restoreLinks(code, linkMeta);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function collectLinkMetadata(cell, typeText) {
|
||||
var anchors = cell.querySelectorAll('a');
|
||||
var lastIndex = 0;
|
||||
var meta = [];
|
||||
|
||||
anchors.forEach(function (anchor) {
|
||||
var text = anchor.textContent.trim();
|
||||
if (!text) {
|
||||
return;
|
||||
}
|
||||
|
||||
var href = anchor.getAttribute('href');
|
||||
var start = typeText.indexOf(text, lastIndex);
|
||||
|
||||
if (start === -1) {
|
||||
start = typeText.indexOf(text);
|
||||
if (start === -1) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
meta.push({
|
||||
start: start,
|
||||
end: start + text.length,
|
||||
href: href
|
||||
});
|
||||
|
||||
lastIndex = start + text.length;
|
||||
});
|
||||
|
||||
return meta;
|
||||
}
|
||||
|
||||
function restoreLinks(codeElement, meta) {
|
||||
var sorted = meta.slice().sort(function (a, b) {
|
||||
return b.start - a.start;
|
||||
});
|
||||
|
||||
sorted.forEach(function (info) {
|
||||
var startPos = findTextPosition(codeElement, info.start);
|
||||
var endPos = findTextPosition(codeElement, info.end);
|
||||
|
||||
if (!startPos || !endPos) {
|
||||
return;
|
||||
}
|
||||
|
||||
var range = document.createRange();
|
||||
range.setStart(startPos.node, startPos.offset);
|
||||
range.setEnd(endPos.node, endPos.offset);
|
||||
|
||||
var anchor = document.createElement('a');
|
||||
anchor.setAttribute('href', info.href);
|
||||
anchor.appendChild(range.extractContents());
|
||||
range.insertNode(anchor);
|
||||
range.detach();
|
||||
});
|
||||
}
|
||||
|
||||
function findTextPosition(container, targetIndex) {
|
||||
var walker = document.createTreeWalker(
|
||||
container,
|
||||
NodeFilter.SHOW_TEXT,
|
||||
null
|
||||
);
|
||||
|
||||
var currentIndex = 0;
|
||||
var currentNode;
|
||||
|
||||
while ((currentNode = walker.nextNode())) {
|
||||
var nextIndex = currentIndex + currentNode.textContent.length;
|
||||
|
||||
if (targetIndex <= nextIndex) {
|
||||
return {
|
||||
node: currentNode,
|
||||
offset: targetIndex - currentIndex
|
||||
};
|
||||
}
|
||||
|
||||
currentIndex = nextIndex;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
@@ -24,6 +24,45 @@
|
||||
return;
|
||||
}
|
||||
|
||||
function ensureCustomClassesAreBuiltIn() {
|
||||
var classesToAdd = ['Redis', 'RedisCluster', 'RedisArray'];
|
||||
|
||||
if (!hljs.getLanguage) {
|
||||
return;
|
||||
}
|
||||
|
||||
var phpLanguage = hljs.getLanguage('php');
|
||||
if (!phpLanguage || !phpLanguage.keywords) {
|
||||
return;
|
||||
}
|
||||
|
||||
var builtIns = phpLanguage.keywords.built_in;
|
||||
if (!builtIns) {
|
||||
phpLanguage.keywords.built_in = classesToAdd.join(' ');
|
||||
return;
|
||||
}
|
||||
|
||||
if (Array.isArray(builtIns)) {
|
||||
classesToAdd.forEach(function (className) {
|
||||
if (builtIns.indexOf(className) === -1) {
|
||||
builtIns.push(className);
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (typeof builtIns === 'string') {
|
||||
classesToAdd.forEach(function (className) {
|
||||
if (builtIns.indexOf(className) === -1) {
|
||||
builtIns += ' ' + className;
|
||||
}
|
||||
});
|
||||
phpLanguage.keywords.built_in = builtIns;
|
||||
}
|
||||
}
|
||||
|
||||
ensureCustomClassesAreBuiltIn();
|
||||
|
||||
var exampleBlocks = document.querySelectorAll('pre.examples');
|
||||
exampleBlocks.forEach(function (block) {
|
||||
if (!block.dataset.language) {
|
||||
@@ -40,6 +79,149 @@
|
||||
}
|
||||
hljs.highlightElement(block);
|
||||
});
|
||||
|
||||
var phpCodeBlocks = document.querySelectorAll('pre code.language-php');
|
||||
phpCodeBlocks.forEach(function (block) {
|
||||
if (block.classList.contains('method-signature')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (block.closest('pre.examples')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (block.parentElement && !block.parentElement.classList.contains('language-php')) {
|
||||
block.parentElement.classList.add('language-php');
|
||||
}
|
||||
|
||||
hljs.highlightElement(block);
|
||||
});
|
||||
|
||||
highlightReturnTypes();
|
||||
|
||||
function highlightReturnTypes() {
|
||||
if (!document.createTreeWalker || !window.NodeFilter) {
|
||||
return;
|
||||
}
|
||||
|
||||
var containers = document.querySelectorAll('.return-value-content');
|
||||
containers.forEach(function (container) {
|
||||
var table = container.querySelector('table');
|
||||
if (!table) {
|
||||
return;
|
||||
}
|
||||
|
||||
table.querySelectorAll('tr').forEach(function (row) {
|
||||
var typeCell = row.querySelector('td');
|
||||
if (!typeCell || typeCell.querySelector('code.return-type')) {
|
||||
return;
|
||||
}
|
||||
|
||||
var typeText = typeCell.textContent.trim();
|
||||
if (!typeText) {
|
||||
return;
|
||||
}
|
||||
|
||||
var linkMeta = collectLinkMetadata(typeCell, typeText);
|
||||
var code = document.createElement('code');
|
||||
code.className = 'return-type language-php';
|
||||
code.textContent = typeText;
|
||||
|
||||
typeCell.innerHTML = '';
|
||||
typeCell.appendChild(code);
|
||||
|
||||
hljs.highlightElement(code);
|
||||
|
||||
if (linkMeta.length) {
|
||||
restoreLinks(code, linkMeta);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function collectLinkMetadata(cell, typeText) {
|
||||
var anchors = cell.querySelectorAll('a');
|
||||
var lastIndex = 0;
|
||||
var meta = [];
|
||||
|
||||
anchors.forEach(function (anchor) {
|
||||
var text = anchor.textContent.trim();
|
||||
if (!text) {
|
||||
return;
|
||||
}
|
||||
|
||||
var href = anchor.getAttribute('href');
|
||||
var start = typeText.indexOf(text, lastIndex);
|
||||
|
||||
if (start === -1) {
|
||||
start = typeText.indexOf(text);
|
||||
if (start === -1) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
meta.push({
|
||||
start: start,
|
||||
end: start + text.length,
|
||||
href: href
|
||||
});
|
||||
|
||||
lastIndex = start + text.length;
|
||||
});
|
||||
|
||||
return meta;
|
||||
}
|
||||
|
||||
function restoreLinks(codeElement, meta) {
|
||||
var sorted = meta.slice().sort(function (a, b) {
|
||||
return b.start - a.start;
|
||||
});
|
||||
|
||||
sorted.forEach(function (info) {
|
||||
var startPos = findTextPosition(codeElement, info.start);
|
||||
var endPos = findTextPosition(codeElement, info.end);
|
||||
|
||||
if (!startPos || !endPos) {
|
||||
return;
|
||||
}
|
||||
|
||||
var range = document.createRange();
|
||||
range.setStart(startPos.node, startPos.offset);
|
||||
range.setEnd(endPos.node, endPos.offset);
|
||||
|
||||
var anchor = document.createElement('a');
|
||||
anchor.setAttribute('href', info.href);
|
||||
anchor.appendChild(range.extractContents());
|
||||
range.insertNode(anchor);
|
||||
range.detach();
|
||||
});
|
||||
}
|
||||
|
||||
function findTextPosition(container, targetIndex) {
|
||||
var walker = document.createTreeWalker(
|
||||
container,
|
||||
NodeFilter.SHOW_TEXT,
|
||||
null
|
||||
);
|
||||
|
||||
var currentIndex = 0;
|
||||
var currentNode;
|
||||
|
||||
while ((currentNode = walker.nextNode())) {
|
||||
var nextIndex = currentIndex + currentNode.textContent.length;
|
||||
|
||||
if (targetIndex <= nextIndex) {
|
||||
return {
|
||||
node: currentNode,
|
||||
offset: targetIndex - currentIndex
|
||||
};
|
||||
}
|
||||
|
||||
currentIndex = nextIndex;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user