Skip to content

Commit 8e2f26f

Browse files
committed
Refine public documentation
1 parent 95b2e00 commit 8e2f26f

File tree

4 files changed

+39
-39
lines changed

4 files changed

+39
-39
lines changed

README.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ The location of temporary files generated by this library is determined by the `
7373
...
7474
{
7575
// Create a unique temporary file
76-
auto tmpfile = tmp::file("org.example.product");
76+
auto tmpfile = tmp::file("org.example.product", ".txt");
7777

7878
// Write its contents and metadata
7979
tmpfile.write(contents);
@@ -106,7 +106,19 @@ To run tests:
106106
ctest --output-on-failure --test-dir build
107107
```
108108

109-
To install the project, run:
109+
## Installing
110+
111+
To install the project, configure it in the Release configuration:
112+
```shell
113+
cmake -B build -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=OFF -DBUILD_SHARED_LIBS=ON
114+
```
115+
116+
build it:
117+
```shell
118+
cmake --build build
119+
```
120+
121+
and then install:
110122
```shell
111123
sudo cmake --install build
112124
```

include/tmp/directory

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,8 @@ namespace tmp {
2020
/// - the managing tmp::directory object is assigned another path via operator=
2121
///
2222
/// The following example uses a tmp::directory object to create a temporary
23-
/// directory with the product identifier label; when the function returns,
24-
/// the tmp::directory object goes out of scope and the temporary directory is
25-
/// deleted along with all of its contents:
23+
/// directory; when the function returns, the tmp::directory object goes out of
24+
/// scope and the temporary directory is deleted along with all of its contents:
2625
///
2726
/// @code{.cpp}
2827
/// #include <tmp/directory>
@@ -37,27 +36,22 @@ namespace tmp {
3736
class TMP_EXPORT directory final : public entry {
3837
public:
3938
/// Creates a unique temporary directory
40-
///
41-
/// The directory path consists of the system's temporary directory path,
42-
/// the given prefix, and random characters to ensure path uniqueness
43-
///
44-
/// @param label A label to attach to the temporary directory path
39+
/// @param label A label to attach to the temporary directory path
4540
/// @throws std::filesystem::filesystem_error if cannot create a directory
4641
/// @throws std::invalid_argument if the label is ill-formatted
4742
explicit directory(std::string_view label = "");
4843

4944
/// Creates a unique temporary copy recursively from the given path
50-
///
51-
/// @param path A path to make a temporary copy from
52-
/// @param label A label to attach to the temporary directory path
45+
/// @param path A path to make a temporary copy from
46+
/// @param label A label to attach to the temporary directory path
5347
/// @returns The new temporary directory
54-
/// @throws std::filesystem::filesystem_error if @p path is not a directory
48+
/// @throws std::filesystem::filesystem_error if given path is not a directory
5549
/// @throws std::invalid_argument if the label is ill-formatted
5650
static directory copy(const std::filesystem::path& path,
5751
std::string_view label = "");
5852

59-
/// Concatenates this directory path with a given @p source
60-
/// @param source A string which represents a path name
53+
/// Concatenates this directory path with a given source
54+
/// @param source A string which represents a path name
6155
/// @returns The result of path concatenation
6256
std::filesystem::path operator/(std::string_view source) const;
6357

include/tmp/entry

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,8 @@ public:
2626

2727
/// Moves the managed path recursively to a given target, releasing
2828
/// ownership of the managed path
29-
///
30-
/// The parent of the target path is created when this function is called
31-
/// @param to A path to the target file or directory
29+
/// @note The target path parent is created when this function is called
30+
/// @param to A path to the target file or directory
3231
/// @throws std::filesystem::filesystem_error if cannot move the owned path
3332
void move(const std::filesystem::path& to);
3433

@@ -39,21 +38,21 @@ public:
3938
auto operator=(const entry&) = delete; ///< not copy-assignable
4039

4140
protected:
42-
/// Constructs a tmp::path which owns @p path
43-
/// @param path A path to manage
41+
/// Creates a temporary entry which owns the given path
42+
/// @param path A path to manage
4443
explicit entry(std::filesystem::path path);
4544

46-
/// Releases the ownership of the managed path;
47-
/// the destructor will not delete the managed path after the call
48-
/// @returns The managed path
49-
std::filesystem::path release() noexcept;
50-
5145
entry(entry&&) noexcept; ///< move-constructible
5246
entry& operator=(entry&&) noexcept; ///< move-assignable
5347

5448
private:
5549
/// The managed path
5650
std::filesystem::path pathobject;
51+
52+
/// Releases the ownership of the managed path
53+
/// @note the destructor will not delete the managed path after the call
54+
/// @returns The full path this entry manages
55+
std::filesystem::path release() noexcept;
5756
};
5857
} // namespace tmp
5958

include/tmp/file

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ namespace tmp {
1515
/// deletes it when this handle goes out of scope
1616
///
1717
/// When a tmp::file object is created, it creates a unique temporary file using
18-
/// the system's default location for temporary files
18+
/// the system's default location for temporary files and opens it for reading
19+
/// and writing
1920
///
2021
/// The managed file is deleted of when either of the following happens:
2122
/// - the managing tmp::file object is destroyed
@@ -32,7 +33,7 @@ namespace tmp {
3233
/// #include <tmp/file>
3334
///
3435
/// auto func(std::string_view content) {
35-
/// auto tmpfile = tmp::file("org.example.product");
36+
/// auto tmpfile = tmp::file("org.example.product", ".txt");
3637
/// tmpfile.write(content);
3738
///
3839
/// // the temporary file is deleted recursively when the
@@ -52,7 +53,6 @@ public:
5253

5354
/// Creates a unique temporary file and opens it for reading and writing
5455
/// in binary mode
55-
///
5656
/// @param label A label to attach to the temporary file path
5757
/// @param extension An extension of the temporary file path
5858
/// @throws std::filesystem::filesystem_error if cannot create a file
@@ -61,7 +61,6 @@ public:
6161

6262
/// Creates a unique temporary file and opens it for reading and writing
6363
/// in text mode
64-
///
6564
/// @param label A label to attach to the temporary file path
6665
/// @param extension An extension of the temporary file path
6766
/// @throws std::filesystem::filesystem_error if cannot create a file
@@ -70,12 +69,11 @@ public:
7069
std::string_view extension = "");
7170

7271
/// Creates a unique temporary copy from the given path
73-
///
7472
/// @param path A path to make a temporary copy from
7573
/// @param label A label to attach to the temporary file path
7674
/// @param extension An extension of the temporary file path
7775
/// @returns The new temporary file
78-
/// @throws std::filesystem::filesystem_error if path is not a file
76+
/// @throws std::filesystem::filesystem_error if given path is not a file
7977
/// @throws std::invalid_argument if arguments are ill-formatted
8078
static file copy(const std::filesystem::path& path,
8179
std::string_view label = "",
@@ -90,11 +88,11 @@ public:
9088
std::string read() const;
9189

9290
/// Writes the given content to this file discarding any previous content
93-
/// @param content A string to write to this file
91+
/// @param content A string to write to this file
9492
void write(std::string_view content) const;
9593

9694
/// Appends the given content to the end of this file
97-
/// @param content A string to append to this file
95+
/// @param content A string to append to this file
9896
void append(std::string_view content) const;
9997

10098
/// Deletes the managed file if its path is not empty
@@ -114,7 +112,6 @@ private:
114112

115113
/// Creates a unique temporary file and opens it for reading and writing
116114
/// in the specified mode
117-
///
118115
/// @param label A label to attach to the temporary file path
119116
/// @param extension An extension of the temporary file path
120117
/// @param binary Whether the managed file is opened in binary write mode
@@ -123,10 +120,8 @@ private:
123120
file(std::string_view label, std::string_view extension, bool binary);
124121

125122
/// Creates a unique temporary file
126-
///
127-
/// @param handle A path to the created temporary file and its
128-
/// implementation-defined handle
129-
/// @param binary Whether the managed file is opened in binary write mode
123+
/// @param handle A path to the created temporary file and its handle
124+
/// @param binary Whether the managed file is opened in binary write mode
130125
file(std::pair<std::filesystem::path, native_handle_type> handle,
131126
bool binary) noexcept;
132127
};

0 commit comments

Comments
 (0)