diff --git a/.gitignore b/.gitignore index 541ba3f198..6e5f29e69b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ /.idea /.vs /.vscode +/.run /CMakeUserPresets.json /CMakeSettings.json /build diff --git a/CMakeLists.txt b/CMakeLists.txt index 14219e4304..89441f78f5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,11 +16,6 @@ #------------------------------------------------- cmake_minimum_required(VERSION 3.13) -if (GENERATOR_IS_MULTI_CONFIG AND NOT CMAKE_CONFIGURATION_TYPES) - set(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "Configurations" FORCE) -elseif(NOT GENERATOR_IS_MULTI_CONFIG AND NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build." FORCE) -endif() project( MrDocs VERSION 0.0.3 @@ -256,7 +251,6 @@ if (WIN32) -D_WIN32_WINNT=0x0601 -D_CRT_SECURE_NO_WARNINGS -D_SILENCE_CXX20_CISO646_REMOVED_WARNING - -DFMT_HEADER_ONLY # because of _ITERATOR_DEBUG_LEVEL ) if(MSVC) get_target_property(LLVM_CONFIGURATION_TYPE LLVMCore IMPORTED_CONFIGURATIONS) diff --git a/bootstrap.py b/bootstrap.py index 5f67d23708..621c4d1d9d 100644 --- a/bootstrap.py +++ b/bootstrap.py @@ -65,14 +65,6 @@ class InstallOptions: # Third-party dependencies third_party_src_dir: str = "/../third-party" - # Fmt - fmt_src_dir: str = "/fmt" - fmt_build_type: str = "" - fmt_build_dir: str = "/build/" - fmt_install_dir: str = "/install/" - fmt_repo: str = "https://github.com/fmtlib/fmt" - fmt_branch: str = "10.2.1" - # Duktape duktape_src_dir: str = "/duktape" duktape_url: str = "https://github.com/svaarala/duktape/releases/download/v2.7.0/duktape-2.7.0.tar.xz" @@ -116,12 +108,6 @@ class InstallOptions: "mrdocs_system_install": "Whether to install MrDocs to the system directories instead of a custom install directory.", "mrdocs_run_tests": "Whether to run tests after building MrDocs.", "third_party_src_dir": "Directory for all third-party source dependencies.", - "fmt_src_dir": "Directory for the fmt library source code.", - "fmt_build_type": "CMake build type for the fmt library. (Release, Debug, RelWithDebInfo, MilRelSize, DebWithOpt)", - "fmt_build_dir": "Directory where the fmt library will be built.", - "fmt_install_dir": "Directory where the fmt library will be installed.", - "fmt_repo": "URL of the fmt library repository to clone.", - "fmt_branch": "Branch or tag of the fmt library to use.", "duktape_src_dir": "Directory for the Duktape source code.", "duktape_url": "Download URL for the Duktape source archive.", "duktape_build_type": "CMake build type for Duktape. (Release, Debug, RelWithDebInfo, MilRelSize, DebWithOpt)", @@ -259,7 +245,7 @@ def repl(match): key = match.group(1) has_dir_key = has_dir_key or key.endswith("-dir") key = key.replace("-", "_") - fmt = match.group(2) + transform_fn = match.group(2) if key == 'os': if self.is_windows(): val = "windows" @@ -271,10 +257,10 @@ def repl(match): raise ValueError("Unsupported operating system.") else: val = getattr(self.options, key, None) - if fmt: - if fmt == "lower": + if transform_fn: + if transform_fn == "lower": val = val.lower() - elif fmt == "upper": + elif transform_fn == "upper": val = val.upper() # Add more formats as needed return val @@ -539,17 +525,6 @@ def setup_third_party_dir(self): self.prompt_dependency_path_option("third_party_src_dir") os.makedirs(self.options.third_party_src_dir, exist_ok=True) - def install_fmt(self): - self.prompt_dependency_path_option("fmt_src_dir") - if not os.path.exists(self.options.fmt_src_dir): - self.prompt_option("fmt_repo") - self.prompt_option("fmt_branch") - self.clone_repo(self.options.fmt_repo, self.options.fmt_src_dir, branch=self.options.fmt_branch, depth=1) - self.prompt_build_type_option("fmt_build_type") - self.prompt_dependency_path_option("fmt_build_dir") - self.prompt_dependency_path_option("fmt_install_dir") - self.cmake_workflow(self.options.fmt_src_dir, self.options.fmt_build_type, self.options.fmt_build_dir, self.options.fmt_install_dir, ["-D", "FMT_DOC=OFF", "-D", "FMT_TEST=OFF"]) - def install_duktape(self): self.prompt_dependency_path_option("duktape_src_dir") if not os.path.exists(self.options.duktape_src_dir): @@ -715,7 +690,6 @@ def create_cmake_presets(self): "Clang_ROOT": self.options.llvm_install_dir, "duktape_ROOT": self.options.duktape_install_dir, "Duktape_ROOT": self.options.duktape_install_dir, - "fmt_ROOT": self.options.fmt_install_dir, "libxml2_ROOT": self.options.libxml2_install_dir, "LibXml2_ROOT": self.options.libxml2_install_dir, "MRDOCS_BUILD_TESTS": self.options.mrdocs_build_tests, @@ -797,7 +771,6 @@ def install_mrdocs(self): "-D", f"Clang_ROOT={self.options.llvm_install_dir}", "-D", f"duktape_ROOT={self.options.duktape_install_dir}", "-D", f"Duktape_ROOT={self.options.duktape_install_dir}", - "-D", f"fmt_ROOT={self.options.fmt_install_dir}" ]) if self.options.mrdocs_build_tests: extra_args.extend([ @@ -828,7 +801,6 @@ def install_all(self): self.check_tools() self.setup_mrdocs_dir() self.setup_third_party_dir() - self.install_fmt() self.install_duktape() if self.options.mrdocs_build_tests: self.install_libxml2() diff --git a/docs/mrdocs.schema.json b/docs/mrdocs.schema.json index 50001dab6f..3dea36755e 100644 --- a/docs/mrdocs.schema.json +++ b/docs/mrdocs.schema.json @@ -131,6 +131,16 @@ "title": "Extraction policy for empty namespaces", "type": "boolean" }, + "extract-friends": { + "default": true, + "description": "Determine whether friend functions and classes should be extracted. When set to `true`, MrDocs extracts friend functions and classes. When set to `false`, friend functions and classes are not extracted.", + "enum": [ + true, + false + ], + "title": "Extraction policy for friend functions and classes", + "type": "boolean" + }, "extract-implicit-specializations": { "default": true, "description": "When set to `true`, MrDocs extracts implicit template specializations used as base classes as dependencies. This allows MrDocs to extract metadata that can later be used to determine the members of the derived class, as specified by the `inherit-base-members` option.", diff --git a/src/lib/AST/ASTVisitor.cpp b/src/lib/AST/ASTVisitor.cpp index be2263c8e4..5783d37009 100644 --- a/src/lib/AST/ASTVisitor.cpp +++ b/src/lib/AST/ASTVisitor.cpp @@ -715,7 +715,9 @@ populate( } // Iterate over the friends of the class - if (D->hasDefinition() && D->hasFriends()) + if (config_->extractFriends && + D->hasDefinition() && + D->hasFriends()) { for (FriendDecl const* FD : D->friends()) { diff --git a/src/lib/AST/ASTVisitor.hpp b/src/lib/AST/ASTVisitor.hpp index 5a0295ec1f..cd44a71eab 100644 --- a/src/lib/AST/ASTVisitor.hpp +++ b/src/lib/AST/ASTVisitor.hpp @@ -684,6 +684,7 @@ class ASTVisitor std::vector>& result, Range&& args) { + std::size_t i = 0; for (TemplateArgument const& arg : args) { if (arg.getIsDefaulted()) @@ -699,8 +700,13 @@ class ASTVisitor } else { - result.emplace_back(toTArg(arg)); + if (i + 1 > result.size()) + { + result.emplace_back(); + } + result[i] = toTArg(arg); } + ++i; } } diff --git a/src/lib/ConfigOptions.json b/src/lib/ConfigOptions.json index da5951c24e..872d456504 100644 --- a/src/lib/ConfigOptions.json +++ b/src/lib/ConfigOptions.json @@ -268,6 +268,13 @@ "type": "bool", "default": true }, + { + "name": "extract-friends", + "brief": "Extraction policy for friend functions and classes", + "details": "Determine whether friend functions and classes should be extracted. When set to `true`, MrDocs extracts friend functions and classes. When set to `false`, friend functions and classes are not extracted.", + "type": "bool", + "default": true + }, { "name": "sort-members", "brief": "Sort the members of a record or namespace", diff --git a/test-files/golden-tests/config/extract-friends/extract-friends.adoc b/test-files/golden-tests/config/extract-friends/extract-friends.adoc new file mode 100644 index 0000000000..3b91a36efd --- /dev/null +++ b/test-files/golden-tests/config/extract-friends/extract-friends.adoc @@ -0,0 +1,105 @@ += Reference +:mrdocs: + +[#index] +== Global namespace + +=== Namespaces + +[cols=1] +|=== +| Name +| link:#std[`std`] +|=== + +=== Types + +[cols=1] +|=== +| Name +| link:#A[`A`] +|=== + +[#std] +== std + +=== Types + +[cols=1] +|=== +| Name +| link:#std-hash-03[`hash`] +| link:#std-hash-08[`hash<A>`] +|=== + +[#std-hash-03] +== link:#std[std]::hash + +=== Synopsis + +Declared in `<extract‐friends.cpp>` + +[source,cpp,subs="verbatim,replacements,macros,-callouts"] +---- +template<class T> +class hash; +---- + +[#std-hash-08] +== link:#std[std]::link:#std-hash-03[hash]<link:#A[A]> + +=== Synopsis + +Declared in `<extract‐friends.cpp>` + +[source,cpp,subs="verbatim,replacements,macros,-callouts"] +---- +template<> +class link:#std-hash-03[hash]<link:#A[A]>; +---- + +=== Member Functions + +[cols=1] +|=== +| Name +| link:#std-hash-08-operator_call[`operator()`] +|=== + +[#std-hash-08-operator_call] +== link:#std[std]::link:#std-hash-08[hash<A>]::operator() + +=== Synopsis + +Declared in `<extract‐friends.cpp>` + +[source,cpp,subs="verbatim,replacements,macros,-callouts"] +---- +unsigned long long +operator()(link:#A[A] const& rhs) const noexcept; +---- + +[#A] +== A + +=== Synopsis + +Declared in `<extract‐friends.cpp>` + +[source,cpp,subs="verbatim,replacements,macros,-callouts"] +---- +class A; +---- + +=== Friends + +[cols=2] +|=== +| Name +| Description +| `link:#std-hash-08[std::hash<A>]` +| +|=== + + +[.small]#Created with https://www.mrdocs.com[MrDocs]# diff --git a/test-files/golden-tests/config/extract-friends/extract-friends.cpp b/test-files/golden-tests/config/extract-friends/extract-friends.cpp new file mode 100644 index 0000000000..b2b2e91eb9 --- /dev/null +++ b/test-files/golden-tests/config/extract-friends/extract-friends.cpp @@ -0,0 +1,20 @@ +namespace std { + template + class hash; +} + +class A { + friend std::hash; +}; + +namespace std { + template <> + class hash { + public: + unsigned long long + operator()(const A&) const noexcept + { + return 0; + } + }; +} \ No newline at end of file diff --git a/test-files/golden-tests/config/extract-friends/extract-friends.html b/test-files/golden-tests/config/extract-friends/extract-friends.html new file mode 100644 index 0000000000..1568b8bd7a --- /dev/null +++ b/test-files/golden-tests/config/extract-friends/extract-friends.html @@ -0,0 +1,164 @@ + + +Reference + + +
+

Reference

+
+
+

+
+

Namespaces

+ + + + + + + + + + +
Name
std
+ +

Types

+ + + + + + + + + + +
Name
A
+ +
+
+
+

std

+
+

Types

+ + + + + + + + + + + +
Name
hash
hash<A>
+ +
+
+ +
+

Synopsis

+
+Declared in <extract-friends.cpp>
+
+
+template<class T>
+class hash;
+
+
+
+ + +
+
+ +
+

Synopsis

+
+Declared in <extract-friends.cpp>
+
+
+template<>
+class hash<A>;
+
+
+
+

Member Functions

+ + + + + + + + + + +
Name
operator()
+ + + +
+
+ +
+

Synopsis

+
+Declared in <extract-friends.cpp>
+
+
+unsigned long long
+operator()(A const& rhs) const noexcept;
+
+
+
+
+
+
+

A

+
+
+

Synopsis

+
+Declared in <extract-friends.cpp>
+
+
+class A;
+
+
+
+ + +
+

Friends

+ + + + + + + + + + + + +|=== + +
NameDescription
hash<A>
+
+
+ +
+
+

Created with MrDocs

+
+ + \ No newline at end of file diff --git a/test-files/golden-tests/config/extract-friends/extract-friends.xml b/test-files/golden-tests/config/extract-friends/extract-friends.xml new file mode 100644 index 0000000000..5795492279 --- /dev/null +++ b/test-files/golden-tests/config/extract-friends/extract-friends.xml @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + diff --git a/test-files/golden-tests/config/extract-friends/extract-friends.yml b/test-files/golden-tests/config/extract-friends/extract-friends.yml new file mode 100644 index 0000000000..cb59c43af6 --- /dev/null +++ b/test-files/golden-tests/config/extract-friends/extract-friends.yml @@ -0,0 +1,2 @@ +extract-friends: true +warn-if-undocumented: false \ No newline at end of file diff --git a/test-files/golden-tests/config/extract-friends/no-extract-friends.adoc b/test-files/golden-tests/config/extract-friends/no-extract-friends.adoc new file mode 100644 index 0000000000..0b50695f0a --- /dev/null +++ b/test-files/golden-tests/config/extract-friends/no-extract-friends.adoc @@ -0,0 +1,95 @@ += Reference +:mrdocs: + +[#index] +== Global namespace + +=== Namespaces + +[cols=1] +|=== +| Name +| link:#std[`std`] +|=== + +=== Types + +[cols=1] +|=== +| Name +| link:#A[`A`] +|=== + +[#std] +== std + +=== Types + +[cols=1] +|=== +| Name +| link:#std-hash-03[`hash`] +| link:#std-hash-08[`hash<A>`] +|=== + +[#std-hash-03] +== link:#std[std]::hash + +=== Synopsis + +Declared in `<no‐extract‐friends.cpp>` + +[source,cpp,subs="verbatim,replacements,macros,-callouts"] +---- +template<class T> +class hash; +---- + +[#std-hash-08] +== link:#std[std]::link:#std-hash-03[hash]<link:#A[A]> + +=== Synopsis + +Declared in `<no‐extract‐friends.cpp>` + +[source,cpp,subs="verbatim,replacements,macros,-callouts"] +---- +template<> +class link:#std-hash-03[hash]<link:#A[A]>; +---- + +=== Member Functions + +[cols=1] +|=== +| Name +| link:#std-hash-08-operator_call[`operator()`] +|=== + +[#std-hash-08-operator_call] +== link:#std[std]::link:#std-hash-08[hash<A>]::operator() + +=== Synopsis + +Declared in `<no‐extract‐friends.cpp>` + +[source,cpp,subs="verbatim,replacements,macros,-callouts"] +---- +unsigned long long +operator()(link:#A[A] const& rhs) const noexcept; +---- + +[#A] +== A + +=== Synopsis + +Declared in `<no‐extract‐friends.cpp>` + +[source,cpp,subs="verbatim,replacements,macros,-callouts"] +---- +class A; +---- + + +[.small]#Created with https://www.mrdocs.com[MrDocs]# diff --git a/test-files/golden-tests/config/extract-friends/no-extract-friends.cpp b/test-files/golden-tests/config/extract-friends/no-extract-friends.cpp new file mode 100644 index 0000000000..bd0b658dd5 --- /dev/null +++ b/test-files/golden-tests/config/extract-friends/no-extract-friends.cpp @@ -0,0 +1,20 @@ +namespace std { +template +class hash; +} + +class A { + friend std::hash; +}; + +namespace std { +template <> +class hash { +public: + unsigned long long + operator()(const A&) const noexcept + { + return 0; + } +}; +} \ No newline at end of file diff --git a/test-files/golden-tests/config/extract-friends/no-extract-friends.html b/test-files/golden-tests/config/extract-friends/no-extract-friends.html new file mode 100644 index 0000000000..0227b3fcb4 --- /dev/null +++ b/test-files/golden-tests/config/extract-friends/no-extract-friends.html @@ -0,0 +1,146 @@ + + +Reference + + +
+

Reference

+
+
+

+
+

Namespaces

+ + + + + + + + + + +
Name
std
+ +

Types

+ + + + + + + + + + +
Name
A
+ +
+
+
+

std

+
+

Types

+ + + + + + + + + + + +
Name
hash
hash<A>
+ +
+
+ +
+

Synopsis

+
+Declared in <no-extract-friends.cpp>
+
+
+template<class T>
+class hash;
+
+
+
+ + +
+
+ +
+

Synopsis

+
+Declared in <no-extract-friends.cpp>
+
+
+template<>
+class hash<A>;
+
+
+
+

Member Functions

+ + + + + + + + + + +
Name
operator()
+ + + +
+
+ +
+

Synopsis

+
+Declared in <no-extract-friends.cpp>
+
+
+unsigned long long
+operator()(A const& rhs) const noexcept;
+
+
+
+
+
+
+

A

+
+
+

Synopsis

+
+Declared in <no-extract-friends.cpp>
+
+
+class A;
+
+
+
+ + +
+ +
+
+

Created with MrDocs

+
+ + \ No newline at end of file diff --git a/test-files/golden-tests/config/extract-friends/no-extract-friends.xml b/test-files/golden-tests/config/extract-friends/no-extract-friends.xml new file mode 100644 index 0000000000..cfdb156a09 --- /dev/null +++ b/test-files/golden-tests/config/extract-friends/no-extract-friends.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + diff --git a/test-files/golden-tests/config/extract-friends/no-extract-friends.yml b/test-files/golden-tests/config/extract-friends/no-extract-friends.yml new file mode 100644 index 0000000000..7a2b9d5296 --- /dev/null +++ b/test-files/golden-tests/config/extract-friends/no-extract-friends.yml @@ -0,0 +1,2 @@ +extract-friends: false +warn-if-undocumented: false \ No newline at end of file diff --git a/test-files/golden-tests/symbols/record/class-template-specializations-3.adoc b/test-files/golden-tests/symbols/record/class-template-specializations-3.adoc index 8761833767..2f054ed99d 100644 --- a/test-files/golden-tests/symbols/record/class-template-specializations-3.adoc +++ b/test-files/golden-tests/symbols/record/class-template-specializations-3.adoc @@ -702,7 +702,7 @@ struct link:#A-0e[A]<float>; |=== | Name | link:#A-01-B-07[`B`] -| link:#A-01-B-08[`B<double, double>`] +| link:#A-01-B-08[`B<double>`] |=== [#A-01-B-07] @@ -719,7 +719,7 @@ struct B; ---- [#A-01-B-08] -== link:#A-01[A<float>]::link:#A-0e-B-07[B]<double, double> +== link:#A-01[A<float>]::link:#A-0e-B-07[B]<double> === Synopsis @@ -728,7 +728,7 @@ Declared in `<class‐template‐specializations‐3.cp [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<> -struct link:#A-0e-B-07[B]<double, double>; +struct link:#A-0e-B-07[B]<double>; ---- === Types @@ -738,11 +738,11 @@ struct link:#A-0e-B-07[B]<double, double>; | Name | link:#A-01-B-08-C[`C`] | link:#A-01-B-08-D-0ae[`D`] -| link:#A-01-B-08-D-0af[`D<bool, bool>`] +| link:#A-01-B-08-D-0af[`D<bool>`] |=== [#A-01-B-08-C] -== link:#A-01[A<float>]::link:#A-01-B-08[B<double, double>]::C +== link:#A-01[A<float>]::link:#A-01-B-08[B<double>]::C === Synopsis @@ -754,7 +754,7 @@ struct C; ---- [#A-01-B-08-D-0ae] -== link:#A-01[A<float>]::link:#A-01-B-08[B<double, double>]::D +== link:#A-01[A<float>]::link:#A-01-B-08[B<double>]::D === Synopsis @@ -767,7 +767,7 @@ struct D; ---- [#A-01-B-08-D-0af] -== link:#A-01[A<float>]::link:#A-01-B-08[B<double, double>]::link:#A-0e-B-00-D-09[D]<bool, bool> +== link:#A-01[A<float>]::link:#A-01-B-08[B<double>]::link:#A-0e-B-00-D-09[D]<bool> === Synopsis @@ -776,7 +776,7 @@ Declared in `<class‐template‐specializations‐3.cp [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<> -struct link:#A-0e-B-00-D-09[D]<bool, bool>; +struct link:#A-0e-B-00-D-09[D]<bool>; ---- [#E] diff --git a/test-files/golden-tests/symbols/record/class-template-specializations-3.html b/test-files/golden-tests/symbols/record/class-template-specializations-3.html index 061c34ae6b..e653195d31 100644 --- a/test-files/golden-tests/symbols/record/class-template-specializations-3.html +++ b/test-files/golden-tests/symbols/record/class-template-specializations-3.html @@ -994,7 +994,7 @@

Types

B -B<double, double> +B<double> @@ -1021,7 +1021,7 @@

Synopsis

Synopsis

@@ -1030,7 +1030,7 @@

Synopsis

 
 template<>
-struct B<double, double>;
+struct B<double>;
 
 
@@ -1045,7 +1045,7 @@

Types

C D -D<bool, bool> +D<bool> @@ -1054,7 +1054,7 @@

Types

Synopsis

@@ -1071,7 +1071,7 @@

Synopsis

Synopsis

@@ -1089,7 +1089,7 @@

Synopsis

Synopsis

@@ -1098,7 +1098,7 @@

Synopsis

 
 template<>
-struct D<bool, bool>;
+struct D<bool>;
 
 
diff --git a/test-files/golden-tests/symbols/record/class-template-specializations-3.xml b/test-files/golden-tests/symbols/record/class-template-specializations-3.xml index b4509e366d..8f1c81e529 100644 --- a/test-files/golden-tests/symbols/record/class-template-specializations-3.xml +++ b/test-files/golden-tests/symbols/record/class-template-specializations-3.xml @@ -239,7 +239,6 @@