Skip to content

Commit

Permalink
Merge pull request idaholab#25607 from GiudGiud/PR_links
Browse files Browse the repository at this point in the history
Add links to moosedocs tagging
  • Loading branch information
cticenhour authored Sep 28, 2023
2 parents 02d970f + fc1018d commit e876aed
Show file tree
Hide file tree
Showing 7 changed files with 163 additions and 147 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ Will generate a mesh that looks like:

Alternatively, the same displacement vectors can be supplied in a file with the `positions_file` option. The above mesh can equivalently be generated with the following.

!listing moose/test/tests/meshgenerators/combiner_generator/combiner_multi_input_translate_from_file.i
!listing test/tests/meshgenerators/combiner_generator/combiner_multi_input_translate_from_file.i
block=Mesh

where the `positions.txt` file contains the floating point triplets.

!listing moose/test/tests/meshgenerators/combiner_generator/positions.txt
!listing test/tests/meshgenerators/combiner_generator/positions.txt

The same restrictions on `positions` also apply to the number of entries in `position_file`.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,4 @@ disabled invalid parameters.
[]
```

!listing moose/test/tests/kernels/simple_diffusion/simple_diffusion.i caption=Input file used to show to formatting
!listing stork/test/tests/kernels/simple_diffusion/simple_diffusion.i caption=Input file used to show to formatting
2 changes: 1 addition & 1 deletion modules/electromagnetics/doc/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Extensions:
MooseDocs.extensions.sqa: disable
MooseDocs.extensions.tagging:
active: True
js_file: index-93b559a6.js
js_file: index-6fae072b.js
allowed_keys:
- example_type
- simulation_type
Expand Down

Large diffs are not rendered by default.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/x-icon" href="../../../media/moose.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Tagging Extension Example</title>
<script type="module" crossorigin src="../../../js/index-93b559a6.js"></script>
<link rel="stylesheet" href="assets/index-d526a0c5.css">
</head>
<body>
<div id="root"></div>

</body>

<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/x-icon" href="../../../media/moose.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Tagging Extension Example</title>
<script type="module" crossorigin src="../../../js/index-6fae072b.js"></script>
<link rel="stylesheet" href="assets/index-d526a0c5.css">
</head>

<body>
<div id="root"></div>

</body>

</html>
23 changes: 18 additions & 5 deletions python/MooseDocs/extensions/tagging.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@
Example output tag dictionary for multiple pages, names, and key:value pairs:
{data:
[{name: "heatconduction", path: "moose/modules/heat_conduction/doc/content/modules/heat_conduction/index.md", key_vals: {keyheat: "valheat", key: "val", key1: "val1"}},
{name: "index", path: "moose/modules/doc/content/index.md", key_vals: {key1: "val1", keya: "val"}},
{name: "index2", path: "moose/modules/doc/content/index2.md", key_vals: {key1: "val1", keya: "val", thing1: "thing2"}},
{name: "geochem", path: "moose/modules/geochemistry/doc/content/modules/geochemistry/index.md", key_vals: {keyg: "valg", keychem: "valuechem"}},
{name: "vortex", path: "moose/modules/level_set/doc/content/modules/level_set/example_vortex.md", key_vals: {keyvor: "valvor", key: "val", key1: "val1"}}]
[{name: "heatconduction", path: "/modules/heat_conduction/doc/content/modules/heat_conduction/index.md", link: "/heat_conduction/doc/content/modules/heat_conduction/index.html", key_vals: {keyheat: "valheat", key: "val", key1: "val1"}},
{name: "index", path: "moose/modules/doc/content/index.md", link: "/doc/content/index.html", key_vals: {key1: "val1", keya: "val"}},
{name: "index2", path: "moose/modules/doc/content/index2.md", link: "/doc/content/index2.html", key_vals: {key1: "val1", keya: "val", thing1: "thing2"}},
{name: "geochem", path: "moose/modules/geochemistry/doc/content/modules/geochemistry/index.md", link: "/geochemistry/doc/content/modules/geochemistry/index.html", key_vals: {keyg: "valg", keychem: "valuechem"}},
{name: "vortex", path: "moose/modules/level_set/doc/content/modules/level_set/example_vortex.md", link: "/level_set/doc/content/modules/level_set/example_vortex.html", key_vals: {keyvor: "valvor", key: "val", key1: "val1"}}]
}
"""

Expand Down Expand Up @@ -98,6 +98,19 @@ def postExecute(self):
for entry in key_list_regex:
regex_replace=f"'{entry}':"
tag_dict_str=re.sub(regex_replace,entry+':', tag_dict_str)
# add relative link built from the path at the end of the tagging entry
if (entry == 'path'):
path_value = tag_dict_str.split("path: ")[1].split(',')[0].replace("'", "")

if 'content/' in path_value:
# splitting at content is dangerous, same named pages within two different modules/xxx/doc/content
# could be mixed together
path_value = path_value.split('content/')[1]

# Use a single / to indicate that it's a local link
link_value = '/' + path_value.replace('.md', '.html')
index = tag_dict_str.find(', key_vals')
tag_dict_str = tag_dict_str[:index] + ', link: "' + link_value + '"' + tag_dict_str[index:]
tag_dict_str=re.sub("'",'"', tag_dict_str)
# Downstream js cannot handle double quotes
tag_dict_str=re.sub("\"\"",'"', tag_dict_str)
Expand Down

0 comments on commit e876aed

Please sign in to comment.