Skip to content

Commit aade90e

Browse files
authored
fix directory titles when underscores are present (#127)
1 parent 7a4aaf5 commit aade90e

File tree

14 files changed

+384
-10
lines changed

14 files changed

+384
-10
lines changed

docs/changelog.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ v0.2.4
2020
the doxygen-breathe-exhale-sphinx ecosystem (and consequently, encouraging me to
2121
resume work on this project).
2222
- Escape ``*`` in template page titles (:pr:`118`).
23+
- Fix titles / links for directories with underscores (:pr:`127`).
2324

2425
v0.2.3
2526
----------------------------------------------------------------------------------------

docs/testing/projects.rst

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,45 +4,51 @@ Testing Projects Module
44
.. automodule:: testing.projects
55
:members:
66

7-
`` testing.projects.c_maths`` Project
7+
``testing.projects.c_maths`` Project
88
----------------------------------------------------------------------------------------
99

1010
.. automodule:: testing.projects.c_maths
1111
:members:
1212

13-
`` testing.projects.cpp with spaces`` Project
13+
``testing.projects.cpp with spaces`` Project
1414
----------------------------------------------------------------------------------------
1515

1616
.. module:: testing.projects.cpp_with_spaces
1717

1818
This cannot be documented because it has spaces in the name and autodoc cannot
1919
complete its import.
2020

21-
`` testing.projects.cpp_fortran_mixed`` Project
21+
``testing.projects.cpp_fortran_mixed`` Project
2222
----------------------------------------------------------------------------------------
2323

2424
.. automodule:: testing.projects.cpp_fortran_mixed
2525
:members:
2626

27-
`` testing.projects.cpp_func_overloads`` Project
27+
``testing.projects.cpp_func_overloads`` Project
2828
----------------------------------------------------------------------------------------
2929

3030
.. automodule:: testing.projects.cpp_func_overloads
3131
:members:
3232

33-
`` testing.projects.cpp_long_names`` Project
33+
``testing.projects.cpp_long_names`` Project
3434
----------------------------------------------------------------------------------------
3535

3636
.. automodule:: testing.projects.cpp_long_names
3737
:members:
3838

39-
`` testing.projects.cpp_nesting`` Project
39+
``testing.projects.cpp_dir_underscores`` Project
40+
----------------------------------------------------------------------------------------
41+
42+
.. automodule:: testing.projects.cpp_dir_underscores
43+
:members:
44+
45+
``testing.projects.cpp_nesting`` Project
4046
----------------------------------------------------------------------------------------
4147

4248
.. automodule:: testing.projects.cpp_nesting
4349
:members:
4450

45-
`` testing.projects.cpp_pimpl`` Project
51+
``testing.projects.cpp_pimpl`` Project
4652
----------------------------------------------------------------------------------------
4753

4854
.. automodule:: testing.projects.cpp_pimpl

docs/testing/tests.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ Project Tests
3939
.. automodule:: testing.tests.cpp_long_names
4040
:members:
4141

42+
``cpp_dir_underscores``
43+
----------------------------------------------------------------------------------------
44+
45+
.. automodule:: testing.tests.cpp_dir_underscores
46+
:members:
47+
4248
``cpp_nesting``
4349
----------------------------------------------------------------------------------------
4450

exhale/graph.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2378,7 +2378,8 @@ class view hierarchy (<a href="..."> for the ``createTreeView = True`` option).
23782378
if node.kind == "namespace":
23792379
title = node.name.split("::")[-1]
23802380
else:
2381-
title = os.path.basename(unique_id.replace("_", os.sep))
2381+
# NOTE: for files, node.name := basename(node.location) aka don't matter
2382+
title = os.path.basename(node.name)
23822383
else:
23832384
unique_id = node.refid
23842385

testing/projects/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ set(EXHALE_PROJECTS
118118
c_maths
119119
cpp_func_overloads
120120
cpp_long_names
121+
cpp_dir_underscores
121122
cpp_nesting
122123
cpp_pimpl
123124
"cpp with spaces"
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
########################################################################################
2+
# This file is dedicated to the public domain. If your jurisdiction requires a #
3+
# specific license: #
4+
# #
5+
# Copyright (c) Stephen McDowell, 2017-2021 #
6+
# License: CC0 1.0 Universal #
7+
# License Text: https://creativecommons.org/publicdomain/zero/1.0/legalcode #
8+
########################################################################################
9+
cmake_minimum_required(VERSION 3.13 FATAL_ERROR)
10+
project(cpp-dir-underscores LANGUAGES CXX)
11+
12+
# "Header only library": add tests and include the directory
13+
target_sources(exhale-projects-unit-tests
14+
PUBLIC
15+
${CMAKE_CURRENT_SOURCE_DIR}/src/tests.cpp
16+
)
17+
target_include_directories(exhale-projects-tests-interface
18+
INTERFACE
19+
${CMAKE_CURRENT_SOURCE_DIR}/include
20+
)
21+
22+
add_open_cpp_coverage_source_dirs(include src)
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
"""
2+
The ``cpp_dir_underscores`` test project.
3+
4+
It primarily exists to make sure directories with underscores in their titles
5+
get the correct link and title names (since exhale uses underscores internally).
6+
"""
7+
8+
from testing.hierarchies import clike, directory, file, namespace
9+
10+
11+
def default_class_hierarchy_dict():
12+
"""Return the default class hierarchy dictionar."""
13+
return {
14+
namespace("interface_alpha"): {
15+
clike("struct", "Alpha"): {},
16+
namespace("one_two_three"): {
17+
clike("struct", "OneTwoThree"): {},
18+
},
19+
namespace("four_five_six"): {
20+
clike("struct", "FourFiveSix"): {}
21+
}
22+
},
23+
namespace("interface_beta"): {
24+
clike("struct", "Beta"): {}
25+
}
26+
}
27+
28+
29+
def default_file_hierarchy_dict():
30+
"""Return the default file hierarchy dictionary."""
31+
return {
32+
directory("include"): {
33+
directory("interface_alpha"): {
34+
file("alpha.hpp"): {
35+
namespace("interface_alpha"): {
36+
clike("struct", "Alpha"): {},
37+
}
38+
},
39+
directory("one_two_three"): {
40+
file("one_two_three.hpp"): {
41+
namespace("interface_alpha"): {
42+
namespace("one_two_three"): {
43+
clike("struct", "OneTwoThree"): {},
44+
}
45+
}
46+
},
47+
},
48+
directory("__four_five_six__"): {
49+
file("__four_five_six__.hpp"): {
50+
namespace("interface_alpha"): {
51+
namespace("four_five_six"): {
52+
clike("struct", "FourFiveSix"): {}
53+
}
54+
}
55+
}
56+
}
57+
},
58+
directory("interface_beta"): {
59+
file("beta.hpp"): {
60+
namespace("interface_beta"): {
61+
clike("struct", "Beta"): {}
62+
}
63+
}
64+
}
65+
}
66+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/***************************************************************************************
2+
* This file is dedicated to the public domain. If your jurisdiction requires a *
3+
* specific license: *
4+
* *
5+
* Copyright (c) Stephen McDowell, 2017-2021 *
6+
* License: CC0 1.0 Universal *
7+
* License Text: https://creativecommons.org/publicdomain/zero/1.0/legalcode *
8+
**************************************************************************************/
9+
#pragma once
10+
11+
#include <string>
12+
13+
namespace interface_alpha {
14+
/// The ``four_five_six`` namespace.
15+
namespace four_five_six {
16+
/// The FourFiveSix struct.
17+
struct FourFiveSix {
18+
/// Returns ``"four_five_six"``.
19+
std::string id() const { return "four_five_six"; }
20+
};
21+
}
22+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/***************************************************************************************
2+
* This file is dedicated to the public domain. If your jurisdiction requires a *
3+
* specific license: *
4+
* *
5+
* Copyright (c) Stephen McDowell, 2017-2021 *
6+
* License: CC0 1.0 Universal *
7+
* License Text: https://creativecommons.org/publicdomain/zero/1.0/legalcode *
8+
**************************************************************************************/
9+
#pragma once
10+
11+
#include <string>
12+
13+
/// The ``interface_alpha`` namespace.
14+
namespace interface_alpha {
15+
/// The Alpha struct.
16+
struct Alpha {
17+
/// Returns ``"alpha"``.
18+
std::string id() const { return "alpha"; }
19+
};
20+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/***************************************************************************************
2+
* This file is dedicated to the public domain. If your jurisdiction requires a *
3+
* specific license: *
4+
* *
5+
* Copyright (c) Stephen McDowell, 2017-2021 *
6+
* License: CC0 1.0 Universal *
7+
* License Text: https://creativecommons.org/publicdomain/zero/1.0/legalcode *
8+
**************************************************************************************/
9+
#pragma once
10+
11+
#include <string>
12+
13+
namespace interface_alpha {
14+
/// The ``one_two_three`` namespace.
15+
namespace one_two_three {
16+
/// The OneTwoThree struct.
17+
struct OneTwoThree {
18+
/// Returns ``"one_two_three"``.
19+
std::string id() const { return "one_two_three"; }
20+
};
21+
}
22+
}

0 commit comments

Comments
 (0)