Skip to content

Commit bc1cbf4

Browse files
committed
stable links: added docu and an end2end test for the copy button
1 parent ecf6e0d commit bc1cbf4

File tree

5 files changed

+182
-0
lines changed

5 files changed

+182
-0
lines changed
10.6 KB
Loading

docs/strictdoc_01_user_guide.sdoc

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2130,6 +2130,34 @@ The options ``--formats=html`` and ``--output-dir output-html`` can be skipped b
21302130
StrictDoc does not detect .sdoc files in the output folder. This is based on the assumption that StrictDoc should not read anything in the output folder, which is intended for transient output artifacts.
21312131
<<<
21322132

2133+
[SECTION]
2134+
MID: dcc6a2bc11424cf2b114b25a7f65530d
2135+
UID: SECTION-UG-Inbound-Links
2136+
TITLE: Inbound Links
2137+
2138+
[TEXT]
2139+
MID: 742831d32ca54791b53c1dbbbd070b55
2140+
STATEMENT: >>>
2141+
To enable integration of StrictDoc with external tools such as bug trackers, project management systems, or wikis, StrictDoc supports stable inbound links to any node that has a ``UID``.
2142+
2143+
To create a stable link, click the "Copy Stable Link" button located in the top-left corner of a requirement or section block:
2144+
2145+
.. image:: _assets/Feature_Copy_Stable_Link.png
2146+
:alt: copy a stable link
2147+
:class: image
2148+
:width: 400
2149+
2150+
The stable links have the form of a URL pointing to the project's main index page, followed by the UID (or MID) as an anchor. For example:
2151+
2152+
``http://your-strictdoc-site/#SDOC_UG_HELLO_WORLD``
2153+
2154+
``http://your-strictdoc-site/#742831d32ca54791b53c1dbbbd070b55``
2155+
2156+
When such a link is opened, StrictDoc automatically resolves the UID (or MID) and forwards the user to the appropriate page and position within the project. This allows requirements to be moved between sections or files without breaking external references.
2157+
<<<
2158+
2159+
[/SECTION]
2160+
21332161
[SECTION]
21342162
MID: 1b41e7c036cf4e3282fa3d4e687bf95d
21352163
TITLE: Standalone HTML pages
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
[GRAMMAR]
2+
ELEMENTS:
3+
- TAG: REQUIREMENT
4+
FIELDS:
5+
- TITLE: MID
6+
TYPE: String
7+
REQUIRED: False
8+
- TITLE: UID
9+
TYPE: String
10+
REQUIRED: False
11+
- TITLE: TITLE
12+
TYPE: String
13+
REQUIRED: False
14+
- TITLE: STATEMENT
15+
TYPE: String
16+
REQUIRED: False
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
[DOCUMENT]
2+
MID: 6a8bc1d467c348dbad29707cd6a3f260
3+
TITLE: Stable URI Test
4+
OPTIONS:
5+
ENABLE_MID: True
6+
MARKUP: HTML
7+
8+
[GRAMMAR]
9+
IMPORT_FROM_FILE: grammar.sgra
10+
11+
[REQUIREMENT]
12+
MID: 7726fa20788c493ca8d02bccd2480a9c
13+
UID: ROOT-1
14+
TITLE: Requirement in root
15+
STATEMENT: <input id="copy_stable_link_form_field">
16+
17+
[SECTION]
18+
MID: 15fa7f4bd56a41eb9da62584961d73b4
19+
TITLE: Section without UID containing a requirement
20+
21+
[REQUIREMENT]
22+
MID: 753286690619492fa9c3ae4f9bf5368d
23+
UID: REQ-WITHIN-SECTION-THAT-HAS-NO-UID
24+
TITLE: Requirment within a Section
25+
STATEMENT: lorem ipsum
26+
27+
[/SECTION]
28+
29+
[SECTION]
30+
MID: 82e3eec5e08146bd8fe213f5a1d8a355
31+
UID: SECTION-1
32+
TITLE: Section that has an UID
33+
34+
[TEXT]
35+
STATEMENT: lorem ipsum
36+
37+
[/SECTION]
38+
39+
[SECTION]
40+
MID: 0915d681276c4f44a1e1930434edc5cf
41+
UID: SECTION-2
42+
TITLE: Section with UID containing a requirement
43+
44+
[REQUIREMENT]
45+
MID: 63414e7641a8445b962c3c1edc91bf0f
46+
UID: REQ-WITHIN-SECTION-2
47+
TITLE: Requirement within a Section that has a UID
48+
STATEMENT: lorem ipsum
49+
50+
[/SECTION]
51+
52+
[SECTION]
53+
MID: 0dd59cda6a3a4ec784d7dc2b5791b92f
54+
UID: SECTION-3
55+
TITLE: Nested Sections Test
56+
57+
[SECTION]
58+
MID: 9978c6da28744db89acbe5875caf5a5c
59+
UID: SECTION-3-1
60+
TITLE: Subsection for the nexted section test
61+
62+
[REQUIREMENT]
63+
MID: 3e06d65b527d4cab87680232880a3430
64+
UID: REQ-WITHIN-SECTION-3-1
65+
TITLE: Requirement within a nested Section
66+
STATEMENT: lorem ipsum
67+
68+
[/SECTION]
69+
70+
[/SECTION]
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import os
2+
import platform
3+
4+
from selenium.webdriver.common.action_chains import ActionChains
5+
from selenium.webdriver.common.keys import Keys
6+
7+
from tests.end2end.e2e_case import E2ECase
8+
from tests.end2end.exporter import SDocTestHTMLExporter
9+
from tests.end2end.helpers.screens.document.screen_document import (
10+
Screen_Document,
11+
)
12+
13+
MODIFIER_KEY = Keys.COMMAND if platform.system() == "Darwin" else Keys.CONTROL
14+
15+
path_to_this_test_file_folder = os.path.dirname(os.path.abspath(__file__))
16+
17+
18+
class Test(E2ECase):
19+
def test_copy_stable_link(self):
20+
with SDocTestHTMLExporter(
21+
input_path=path_to_this_test_file_folder
22+
) as exporter:
23+
target = "ROOT-1"
24+
25+
# open the project index with the target UID reference
26+
self.open(
27+
exporter.get_output_path_as_uri()
28+
+ "copy_stable_link/input/index.html#"
29+
+ target
30+
)
31+
32+
screen_document = Screen_Document(self)
33+
screen_document.assert_on_screen("document")
34+
35+
# move mouse to hover over target, so that button becomes visible
36+
screen_document.test_case.hover_on_element(
37+
f'//sdoc-field-content[sdoc-autogen[text()="{target}"]]'
38+
)
39+
40+
# now click on the target's copy_stable_link button
41+
screen_document.test_case.click_xpath(
42+
f'//div[@class="copy_stable_link-button" and @data-path="../../#{target}"]'
43+
)
44+
45+
# focus on the input field
46+
screen_document.test_case.click_xpath(
47+
'//input[@id="copy_stable_link_form_field"]'
48+
)
49+
50+
# Send Ctrl+V to paste clipboard content into input field
51+
actions = ActionChains(screen_document.test_case.driver)
52+
actions.key_down(MODIFIER_KEY).send_keys("v").key_up(
53+
MODIFIER_KEY
54+
).perform()
55+
56+
# read the content of the input field
57+
input_field = screen_document.test_case.find_element(
58+
'//input[@id="copy_stable_link_form_field"]'
59+
)
60+
61+
# Get the text from the input field
62+
value = input_field.get_attribute("value")
63+
64+
# check if stable link is as expected
65+
assert (
66+
value
67+
== exporter.get_output_path_as_uri() + "index.html#" + target
68+
)

0 commit comments

Comments
 (0)