Skip to content

Commit ddb96a9

Browse files
committed
Add more documentation comments by iFlow CLI
1 parent d6548bf commit ddb96a9

File tree

11 files changed

+331
-215
lines changed

11 files changed

+331
-215
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
- Reproducible dependency management via [CPM.cmake](https://github.com/TheLartians/CPM.cmake)
2323
- Installable target with automatic versioning information and header generation via [PackageProject.cmake](https://github.com/TheLartians/PackageProject.cmake)
2424
- Automatic [documentation](https://thelartians.github.io/ModernCppStarter) and deployment with [Doxygen](https://www.doxygen.nl) and [GitHub Pages](https://pages.github.com)
25-
- Support for [sanitizer tools, and more](#additional-tools)
25+
- Support for sanitizer tools and more
2626

2727
## Usage
2828

@@ -41,7 +41,7 @@ Eventually, you can remove any unused files, such as the standalone directory or
4141
Feel free to replace the License with one suited for your project.
4242

4343
To cleanly separate the library and subproject code, the outer `CMakeList.txt` only defines the library itself while the tests and other subprojects are self-contained in their own directories.
44-
During development it is usually convenient to [build all subprojects at once](#build-everything-at-once).
44+
During development it is usually convenient to build all subprojects at once.
4545

4646
### Build and run the standalone target
4747

documentation/Doxyfile

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,4 @@ GENERATE_LATEX = NO
2626
XML_PROGRAMLISTING = NO
2727
CREATE_SUBDIRS = NO
2828

29-
# Include all directories, files and namespaces in the documentation
30-
# Disable to include only explicitly documented objects
31-
M_SHOW_UNDOCUMENTED = YES
29+

documentation/conf.py

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,24 @@
1+
import warnings
2+
import logging
3+
4+
# Suppress Python deprecation warnings about testing element truth values
5+
warnings.filterwarnings("ignore", category=DeprecationWarning, message=".*Testing an element's truth value.*")
6+
7+
# Suppress warnings about external images not found in XML output
8+
warnings.filterwarnings("ignore", message=".*was not found in XML_OUTPUT", category=RuntimeWarning)
9+
warnings.filterwarnings("ignore", message=".*was not found in XML_OUTPUT", category=UserWarning)
10+
11+
# Suppress the specific logging messages about external images in m.css
12+
class ImageNotFoundFilter(logging.Filter):
13+
def filter(self, record):
14+
# Suppress specific image not found messages
15+
if "was not found in XML_OUTPUT" in record.getMessage():
16+
return False
17+
return True
18+
19+
# Apply the filter to the root logger
20+
logging.getLogger().addFilter(ImageNotFoundFilter())
21+
122
DOXYFILE = 'Doxyfile'
223

324
LINKS_NAVBAR1 = [
@@ -10,10 +31,10 @@
1031

1132
# LINKS_NAVBAR1 = [
1233
# (None, 'pages', [(None, 'about')]),
13-
# (None, 'namespaces', [(None, 'namespacepy2cpp')]),
34+
# (None, 'namespaces', [(None, 'namespacexnetwork')]),
1435
# ]
1536
#
1637
# LINKS_NAVBAR2 = [
17-
# (None, 'annotated', [(None, 'classpy2cpp_1_1_py2cpp')]),
18-
# (None, 'files', [(None, 'py2cpp_8h')]),
38+
# (None, 'annotated', [(None, 'classxnetwork_1_1_xnetwork')]),
39+
# (None, 'files', [(None, 'xnetwork_8h')]),
1940
# ]

include/py2cpp/dict.hpp

Lines changed: 71 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,49 @@
1111
namespace py {
1212

1313
/**
14-
* @brief
14+
* @brief Iterator adapter for accessing keys in map-like containers
15+
*
16+
* Provides an iterator that dereferences to the key component of
17+
* key-value pairs in map-like containers.
1518
*
16-
* @tparam Iter
19+
* @tparam Iter The underlying iterator type for key-value pairs
1720
*/
1821
template <typename Iter> struct key_iterator : Iter {
22+
/**
23+
* @brief Construct a key iterator from an underlying iterator
24+
*
25+
* @param[in] it The underlying iterator for key-value pairs
26+
*/
1927
explicit key_iterator(Iter it) : Iter(it) {}
28+
29+
/**
30+
* @brief Dereference to get the key (const version)
31+
*
32+
* @return const auto& Reference to the key
33+
*/
2034
auto operator*() const -> const auto & { return Iter::operator*().first; }
35+
36+
/**
37+
* @brief Dereference to get the key (non-const version)
38+
*
39+
* @return const auto& Reference to the key
40+
*/
2141
auto operator*() -> const auto & { return Iter::operator*().first; }
42+
43+
/**
44+
* @brief Pre-increment operator
45+
*
46+
* @return key_iterator& Reference to this iterator
47+
*/
2248
auto operator++() -> key_iterator & {
2349
Iter::operator++();
2450
return *this;
2551
}
52+
/**
53+
* @brief Post-increment operator
54+
*
55+
* @return key_iterator Copy of this iterator before increment
56+
*/
2657
auto operator++(int) -> key_iterator {
2758
auto old = *this;
2859
++*this;
@@ -31,10 +62,13 @@ namespace py {
3162
};
3263

3364
/**
34-
* @brief
65+
* @brief Python-like dictionary implementation
3566
*
36-
* @tparam Key
37-
* @tparam T
67+
* A dictionary class that extends std::unordered_map with Python-like
68+
* convenience methods and functionality.
69+
*
70+
* @tparam Key The key type
71+
* @tparam T The value type
3872
*/
3973
template <typename Key, typename T> class dict : public std::unordered_map<Key, T> {
4074
using Self = dict<Key, T>;
@@ -45,33 +79,38 @@ namespace py {
4579
using key_type = Key;
4680

4781
/**
48-
* @brief Construct a new dict object
82+
* @brief Default constructor
4983
*
84+
* Creates an empty dictionary.
5085
*/
5186
dict() : Base{} {}
5287

5388
/**
54-
* @brief Construct a new dict object
89+
* @brief Construct a dict from an initializer list
90+
*
91+
* Creates a dictionary from a list of key-value pairs.
5592
*
56-
* @param[in] init
93+
* @param[in] init Initializer list of key-value pairs
5794
*/
5895
dict(std::initializer_list<value_type> init) : Base{init} {}
5996

6097
/**
61-
* @brief
98+
* @brief Check if the dictionary contains a specific key
6299
*
63100
* @param[in] key
64-
* @return true
65-
* @return false
101+
* @return true if the key is contained in the dictionary, false otherwise
66102
*/
67103
auto contains(const Key &key) const -> bool { return this->find(key) != this->end(); }
68104

69105
/**
70-
* @brief
106+
* @brief Get a value with a default fallback
71107
*
72-
* @param[in] key
73-
* @param[in] default_value
74-
* @return T
108+
* Returns the value associated with the key, or the default value
109+
* if the key is not found in the dictionary.
110+
*
111+
* @param[in] key The key to look up
112+
* @param[in] default_value The default value to return if key is not found
113+
* @return T The value associated with the key, or the default value
75114
*/
76115
auto get(const Key &key, const T &default_value) const -> T {
77116
if (!contains(key)) {
@@ -81,36 +120,44 @@ namespace py {
81120
}
82121

83122
/**
84-
* @brief
123+
* @brief Get iterator to the beginning of keys
124+
*
125+
* Returns an iterator that yields keys from the dictionary.
85126
*
86-
* @return auto
127+
* @return auto Iterator to the first key
87128
*/
88129
auto begin() -> key_iterator<decltype(Base::begin())> {
89130
return key_iterator<decltype(Base::begin())>{Base::begin()};
90131
}
91132

92133
/**
93-
* @brief
134+
* @brief Get iterator to the end of keys
135+
*
136+
* Returns an iterator past the last key in the dictionary.
94137
*
95-
* @return auto
138+
* @return auto Iterator past the last key
96139
*/
97140
auto end() -> key_iterator<decltype(Base::end())> {
98141
return key_iterator<decltype(Base::end())>{Base::end()};
99142
}
100143

101144
/**
102-
* @brief
145+
* @brief Get const iterator to the beginning of keys
146+
*
147+
* Returns a const iterator that yields keys from the dictionary.
103148
*
104-
* @return auto
149+
* @return auto Const iterator to the first key
105150
*/
106151
auto begin() const -> key_iterator<decltype(Base::begin())> {
107152
return key_iterator<decltype(Base::begin())>{Base::begin()};
108153
}
109154

110155
/**
111-
* @brief
156+
* @brief Get const iterator to the end of keys
157+
*
158+
* Returns a const iterator past the last key in the dictionary.
112159
*
113-
* @return auto
160+
* @return auto Const iterator past the last key
114161
*/
115162
auto end() const -> key_iterator<decltype(Base::end())> {
116163
return key_iterator<decltype(Base::end())>{Base::end()};
@@ -200,8 +247,7 @@ namespace py {
200247
* @tparam T
201248
* @param[in] key
202249
* @param[in] m
203-
* @return true
204-
* @return false
250+
* @return true if the key is contained in the dictionary, false otherwise
205251
*/
206252
template <typename Key, typename T> inline auto operator<(const Key &key, const dict<Key, T> &m) noexcept
207253
-> bool {

include/py2cpp/enumerate.hpp

Lines changed: 30 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,12 @@ namespace py {
1010
namespace detail {
1111

1212
/**
13-
* @brief EnumerateIterator
13+
* @brief Iterator for enumerated access to container elements
1414
*
15-
* The code defines a struct called `EnumerateIterator` that is used to iterate
16-
* over a container or range and provide the index of each element in the
17-
* iteration.
15+
* Provides iterator functionality that yields index-value pairs when
16+
* iterating over containers, similar to Python's enumerate() function.
1817
*
19-
* @tparam T
18+
* @tparam T The container or range type to enumerate
2019
*/
2120
template <typename T> struct EnumerateIterator {
2221
typedef decltype(std::begin(std::declval<T>())) TIter;
@@ -26,33 +25,23 @@ namespace py {
2625
TIter iter;
2726

2827
/**
29-
* @brief Not equal to
28+
* @brief Check inequality between iterators
3029
*
31-
* The `operator!=` function is an overloaded operator that checks for
32-
* inequality between two `EnumerateIterator` objects. It compares the
33-
* `iter` member of the current object with the `iter` member of the `other`
34-
* object. If they are not equal, it returns `true`, indicating that the two
35-
* iterators are not pointing to the same element. Otherwise, it returns
36-
* `false`, indicating that the two iterators are equal.
30+
* Compares the underlying iterators to determine if they point to different elements.
3731
*
38-
* @param[in] other
39-
* @return true
40-
* @return false
32+
* @param[in] other The other iterator to compare with
33+
* @return true if the iterators are not equal, false otherwise
4134
*/
4235
auto operator!=(const EnumerateIterator &other) const -> bool {
4336
return iter != other.iter;
4437
}
4538

4639
/**
47-
* @brief
40+
* @brief Pre-increment operator
4841
*
49-
* The `operator++()` function is an overloaded operator that increments the
50-
* `EnumerateIterator` object. It increases the value of the `i` member
51-
* variable by 1 and advances the `iter` member variable to the next element
52-
* in the iteration. It then returns a reference to the updated
53-
* `EnumerateIterator` object.
42+
* Increments both the index counter and the underlying iterator.
5443
*
55-
* @return EnumerateIterator&
44+
* @return EnumerateIterator& Reference to this iterator
5645
*/
5746
EnumerateIterator &operator++() {
5847
++i;
@@ -61,57 +50,45 @@ namespace py {
6150
}
6251

6352
/**
64-
* @brief
53+
* @brief Dereference operator
6554
*
66-
* The `operator*()` function is an overloaded operator that returns the
67-
* current element in the iteration as a `std::pair<size_t, iter_ref>`. The
68-
* `size_t` value represents the index of the element, and the `iter_ref`
69-
* value represents a reference to the element itself. This allows you to
70-
* access both the index and the element in a single expression when using
71-
* the `enumerate()` function.
55+
* Returns a pair containing the current index and a reference to the element.
7256
*
73-
* @return std::pair<size_t, iter_ref>
57+
* @return std::pair<size_t, iter_ref> Pair of (index, element_reference)
7458
*/
7559
auto operator*() -> std::pair<size_t, iter_ref> {
7660
return std::pair<size_t, iter_ref>{i, *iter};
7761
}
7862
};
7963

8064
/**
81-
* @brief EnumerateIterableWrapper
65+
* @brief Wrapper for making containers enumerable
8266
*
83-
* The code defines a struct called `EnumerateIterableWrapper` that acts as a
84-
* wrapper for an iterable object. It provides two member functions, `begin()`
85-
* and `end()`, which return instances of the `EnumerateIterator` struct.
67+
* Provides begin/end methods that return EnumerateIterator instances,
68+
* enabling range-based for loops with index-value pairs.
8669
*
87-
* @tparam T
70+
* @tparam T The container type to wrap
8871
*/
8972
template <typename T> struct EnumerateIterableWrapper {
9073
T &iterable;
9174

9275
/**
93-
* @brief begin
76+
* @brief Get iterator to the beginning
9477
*
95-
* The `begin()` function is a member function of the
96-
* `EnumerateIterableWrapper` struct. It returns an instance of the
97-
* `EnumerateIterator<T>` struct, which is used to iterate over the elements
98-
* of the iterable object.
78+
* Returns an EnumerateIterator pointing to the start of the container.
9979
*
100-
* @return EnumerateIterator<T>
80+
* @return EnumerateIterator<T> Iterator to the beginning
10181
*/
10282
auto begin() const -> EnumerateIterator<T> {
10383
return EnumerateIterator<T>{0, std::begin(iterable)};
10484
}
10585

10686
/**
107-
* @brief end
87+
* @brief Get iterator to the end
10888
*
109-
* The `end()` function is a member function of the
110-
* `EnumerateIterableWrapper` struct. It returns an instance of the
111-
* `EnumerateIterator<T>` struct, which is used to mark the end of the
112-
* iteration over the elements of the iterable object.
89+
* Returns an EnumerateIterator pointing past the end of the container.
11390
*
114-
* @return EnumerateIterator<T>
91+
* @return EnumerateIterator<T> Iterator past the end
11592
*/
11693
auto end() const -> EnumerateIterator<T> {
11794
return EnumerateIterator<T>{0, std::end(iterable)};
@@ -121,17 +98,14 @@ namespace py {
12198
} // namespace detail
12299

123100
/**
124-
* @brief enumerate(T &iterable)
101+
* @brief Create an enumerable wrapper for a container
125102
*
126-
* The `enumerate(T &iterable)` function is a utility function that allows you
127-
* to iterate over a container or range and also get the index of each element
128-
* in the iteration. It returns an instance of the
129-
* `detail::EnumerateIterableWrapper<T>` class, which provides a range-based for
130-
* loop compatible interface.
103+
* Returns a wrapper that allows iteration over container elements with their indices,
104+
* similar to Python's enumerate() function.
131105
*
132-
* @tparam T
133-
* @param[in] iterable
134-
* @return detail::EnumerateIterableWrapper<T>
106+
* @tparam T The container type
107+
* @param[in] iterable Reference to the container to enumerate
108+
* @return detail::EnumerateIterableWrapper<T> Wrapper for enumerated iteration
135109
*/
136110
template <typename T> inline auto enumerate(T &iterable)
137111
-> detail::EnumerateIterableWrapper<T> {

0 commit comments

Comments
 (0)