forked from Qiskit/documentation
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make link extraction from markdown more explicit (Qiskit#628)
This is prework for Qiskit#522, which adds `sphinx.inv`. We want to check the links contained in `sphinx.inv`, but we don't expect anyone to have links pointing to `sphinx.inv`. Our original abstractions made it hard to model `objects.inv` correctly with the link checker. Now, `markdown.ts` is renamed to `extractLinks.ts` and it solely deals with parsing files. It no longer has a bad coupling to the complex `linksToOriginFiles` variable from `FileBatch.ts`. This should make it much more obvious how to handle `objects.inv`. --------- Co-authored-by: Frank Harkins <frankharkins@hotmail.co.uk>
- Loading branch information
1 parent
65497cc
commit a2d7b9a
Showing
6 changed files
with
120 additions
and
67 deletions.
There are no files selected for viewing
This file contains 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 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 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,35 @@ | ||
// This code is a Qiskit project. | ||
// | ||
// (C) Copyright IBM 2024. | ||
// | ||
// This code is licensed under the Apache License, Version 2.0. You may | ||
// obtain a copy of this license in the LICENSE file in the root directory | ||
// of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. | ||
// | ||
// Any modifications or derivative works of this code must retain this | ||
// copyright notice, and modified files need to carry a notice indicating | ||
// that they have been altered from the originals. | ||
|
||
import { expect, test } from "@jest/globals"; | ||
import { addLinksToMap } from "./FileBatch"; | ||
|
||
test("addLinksToMap()", () => { | ||
const linksToMap = new Map(); | ||
|
||
addLinksToMap("file1.md", ["https://ibm.com", "./relative"], linksToMap); | ||
expect(linksToMap).toEqual( | ||
new Map([ | ||
["https://ibm.com", ["file1.md"]], | ||
["./relative", ["file1.md"]], | ||
]), | ||
); | ||
|
||
addLinksToMap("file2.md", ["./relative", "/images/my_image.png"], linksToMap); | ||
expect(linksToMap).toEqual( | ||
new Map([ | ||
["https://ibm.com", ["file1.md"]], | ||
["./relative", ["file1.md", "file2.md"]], | ||
["/images/my_image.png", ["file2.md"]], | ||
]), | ||
); | ||
}); |
This file contains 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 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 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