Repository navigation
fix: restore graph assets, search reopening and member permalinks #14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| category: fixed | ||
| type: patch | ||
| --- | ||
|
|
||
| Preserves shared graph-page assets and initializes zoom controls after loading their dependency. Cancels pending zoom animation before resetting the diagram. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| category: fixed | ||
| type: patch | ||
| --- | ||
|
|
||
| Scopes member tag and attribute IDs and replaces existing fragments in section permalinks. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| category: fixed | ||
| type: patch | ||
| --- | ||
|
|
||
| Restores search results and active state when reopening an unchanged query. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace FastForward\Documentation; | ||
|
|
||
| #[\Attribute(\Attribute::TARGET_METHOD)] | ||
| final class ExampleAttribute | ||
| { | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| const assert = require('node:assert/strict'); | ||
| const fs = require('node:fs'); | ||
| const path = require('node:path'); | ||
| const vm = require('node:vm'); | ||
| const root = process.env.TEMPLATE_ROOT || path.join(__dirname, '..'); | ||
| function element() { | ||
| const classes = new Set(); | ||
| return {listeners: {}, classList: {add(...xs) {xs.forEach(x => classes.add(x));}, remove(...xs) {xs.forEach(x => classes.delete(x));}, contains(x) {return classes.has(x);}}, addEventListener(n, f) {this.listeners[n] = f;}, setAttribute() {}, removeAttribute() {}, contains() {return false;}, value: '', innerHTML: '', blur() {}}; | ||
| } | ||
| const form = element(), field = element(), results = element(), entries = element(), close = element(), clear = element(), body = element(); | ||
| const nodes = {'[data-search-form]': form, '[data-search-form] input[type="search"]': field, '[data-search-results]': results, '[data-search-results] .phpdocumentor-search-results__entries': entries, '.phpdocumentor-search-results__close': close, '[data-search-clear]': clear}; | ||
| const documentListeners = {}, windowListeners = {}; | ||
| const context = {document: {querySelector: s => nodes[s], body, addEventListener(name, callback) {documentListeners[name] = callback;}, createElement() {return {set textContent(v) {this.innerHTML = v;}};}}, window: {addEventListener(name, callback) {windowListeners[name] = callback;}}, Fuse: function () {this.search = value => value === 'missing' ? [] : [{name: 'Example', url: 'classes/Example.html'}];}, setTimeout(f) {f(); return 1;}, clearTimeout() {}}; | ||
| vm.createContext(context); | ||
| vm.runInContext(fs.readFileSync(path.join(root, 'js/search.js.twig'), 'utf8'), context); | ||
| context.Search.init(); | ||
| const event = {target: field, stopPropagation() {}, preventDefault() {}}; | ||
| for (const query of ['Example', 'missing']) { | ||
| field.value = query; | ||
| field.listeners.keyup(event); | ||
| const original = entries.innerHTML; | ||
| assert.ok(original); | ||
| for (const dismiss of [() => close.listeners.click(event), () => documentListeners.click(event), () => windowListeners.keyup({...event, key: 'Escape'})]) { | ||
| dismiss(); | ||
| assert.equal(entries.innerHTML, ''); | ||
| field.listeners.focus(event); | ||
| assert.equal(entries.innerHTML, original, 'Reopening must regenerate unchanged-query results'); | ||
| assert.ok(body.classList.contains('phpdocumentor-search--active-body')); | ||
| assert.ok(form.classList.contains('phpdocumentor-search--has-results')); | ||
| assert.ok(results.classList.contains('show')); | ||
| } | ||
| } | ||
| clear.listeners.click(event); | ||
| assert.equal(field.value, ''); | ||
| assert.equal(entries.innerHTML, ''); | ||
| assert.ok(!results.classList.contains('show')); | ||
| console.log('PASS search reopen, empty results, state and clear'); | ||
| const graph = fs.readFileSync(path.join(root, 'graphs/class.html.twig'), 'utf8'); | ||
| const scripts = graph.match(/{% block javascripts %}([\s\S]*?){% endblock %}/)[1]; | ||
| assert.match(graph, /{% block stylesheets %}\s*{{ parent\(\) }}/); | ||
| assert.match(scripts, /{{ parent\(\) }}/); | ||
| assert.ok(scripts.indexOf('panzoom.min.js') < scripts.indexOf('var instance = panzoom')); | ||
| assert.ok(scripts.includes('var instance = panzoom'), 'Graph initialization must live after its footer dependency'); | ||
| const graphNodes = {}; | ||
| const calls = []; | ||
| let pendingZoom = null, scale = 1; | ||
| vm.runInNewContext(scripts.match(/<script>([\s\S]*?)<\/script>/)[1], {document: {getElementById(id) {return graphNodes[id] ||= {...element(), style: {}};}}, panzoom() {return {smoothZoom(...args) {calls.push(args); pendingZoom = () => {scale = args[2];};}, zoomTo(...args) {calls.push(args); pendingZoom = null;}, moveTo(...args) {calls.push(args);}, zoomAbs(...args) {calls.push(args); scale = args[2];}};}}); | ||
| graphNodes['zoom-in'].listeners.click(); | ||
| graphNodes['zoom-out'].listeners.click(); | ||
| graphNodes['reset-panzoom'].listeners.click(); | ||
| if (pendingZoom) pendingZoom(); | ||
| assert.equal(scale, 1, 'Reset must cancel in-flight zoom animation'); | ||
| assert.deepEqual(calls, [[0, 0, 1.2], [0, 0, 0.8], [0, 0, 1], [0, 0], [0, 0, 1]]); | ||
| console.log('PASS graph inherited assets, dependency ordering and controls'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.