aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/scripts
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2021-10-21 12:26:18 +0100
committerJonathan Wakely <jwakely@redhat.com>2021-10-21 22:24:57 +0100
commit394f60e6ed9fbf3a833024041ec8ec26bde5aa3b (patch)
tree65b01e7dfdd61ca634fd2063a8e96c548f29bbe9 /libstdc++-v3/scripts
parent5a5d7c2c802f005f8cf85e0bfb7a77cf13203dae (diff)
downloadgcc-394f60e6ed9fbf3a833024041ec8ec26bde5aa3b.zip
gcc-394f60e6ed9fbf3a833024041ec8ec26bde5aa3b.tar.gz
gcc-394f60e6ed9fbf3a833024041ec8ec26bde5aa3b.tar.bz2
libstdc++: Improve generated man pages for libstdc++
The man pages generated by Doxygen show internal header files, not the standard headers that users actually care about. The run_doxygen script uses the doc/doxygen/stdheader.cc program to address that, but it doesn't work. It only tries to fix headers with underscores in the names, which doesn't work for <bits/align.h> or <bits/fsteam.tcc>. It isn't prepared for the strings like "bits/stl_set\&.h" that are produced by Doxygen. It doesn't know about many headers that have been added since it was written. And the run_doxygen script fails to use its output correctly to modify the man pages. Additionally, run_doxygen doesn't know about new nested namespaces like std::filesystem and std::ranges. This change rewrites the stdheader.cc program to do a better job of finding the right header. The run_doxygen script now uses the just-built compiler to build stdheader.cc and actually uses its output. And the script now knows about other nested namespaces. The stdheader.cc program might be unnecessary if we consistently used @headername tags in the Doxygen comments, but we don't (and probably never will). A problem that remains after this change is that all the free function defined in namespace std get dumped into a single man page for std(3), without detailed descriptions. We don't even install that std(3) page, but remove it before installation. That means only classes are documented in man pages (including many internal ones that should not be publicly documented such as _Deque_base and _Tuple_impl). libstdc++-v3/ChangeLog: * doc/doxygen/stdheader.cc: Refactor. Use C++23. Add new headers. * scripts/run_doxygen: Fix post-processing of #include directives in man pages. Use new xg++ to compile helper program.
Diffstat (limited to 'libstdc++-v3/scripts')
-rw-r--r--libstdc++-v3/scripts/run_doxygen34
1 files changed, 25 insertions, 9 deletions
diff --git a/libstdc++-v3/scripts/run_doxygen b/libstdc++-v3/scripts/run_doxygen
index a367721..6236a07 100644
--- a/libstdc++-v3/scripts/run_doxygen
+++ b/libstdc++-v3/scripts/run_doxygen
@@ -269,6 +269,8 @@ find . -name "* *" -print0 | xargs -0r rm # requires GNU tools
# man pages are for functions/types/other entities, not source files
# directly. who the heck would type "man foo.h" anyhow?
+# FIXME: This also removes std.3 which is the only place that a lot of
+# functions are documented. Should we keep it?
find . -name "[a-z]*" -a ! -name "std_*" -print | xargs rm
rm -f *.h.3 *.hpp.3 *config* *.cc.3 *.tcc.3 *_t.3
#rm ext_*.3 tr1_*.3 debug_*.3
@@ -278,18 +280,23 @@ rm -f *.h.3 *.hpp.3 *config* *.cc.3 *.tcc.3 *_t.3
#find . -name "[a-z]*" -a ! -name "std_*" -print | xargs -i mv {} trash
#mv *.h.3 *config* *.cc.3 *.tcc.3 *_t.3 trash
+gxx=$($builddir/scripts/testsuite_flags --build-cxx)
+cppflags=$($builddir/scripts/testsuite_flags --build-includes)
+cxxflags="-Og -g -std=gnu++23"
+
# Standardize the displayed header names. If anyone who knows perl cares
# enough to rewrite all this, feel free. This only gets run once a century,
# and I'm off getting coffee then anyhow, so I didn't care enough to make
# this super-fast.
-g++ ${srcdir}/doc/doxygen/stdheader.cc -o ./stdheader
-problematic=`egrep -l '#include <.*_.*>' [a-z]*.3`
+$gxx $cppflags $cxxflags ${srcdir}/doc/doxygen/stdheader.cc -o ./stdheader || exit 1
+# Doxygen outputs something like "\fC#include <unique_lock\&.h>\fP" and
+# we want that internal header to be replaced with something like <mutex>.
+problematic=`egrep -l '#include <.*h>' [a-z]*.3`
for f in $problematic; do
# this is also slow, but safe and easy to debug
oldh=`sed -n '/fC#include </s/.*<\(.*\)>.*/\1/p' $f`
- newh=`echo $oldh | ./stdheader`
- sed 's=${oldh}=${newh}=' $f > TEMP
- mv TEMP $f
+ newh=`echo $oldh | sed 's/\\\\&\\././g' | ./stdheader`
+ sed "s=${oldh/\\/.}=${newh}=" $f > TEMP && mv TEMP $f
done
rm stdheader
@@ -323,10 +330,14 @@ cp ${srcdir}/doc/doxygen/Intro.3 C++Intro.3
# Why didn't I do this at the start? Were rabid weasels eating my brain?
# Who the fsck would "man std_vector" when the class isn't named that?
+# If no files match a glob, skip the for-loop:
+shopt -s nullglob
# First, deal with nested namespaces.
-for f in *chrono_*; do
- newname=`echo $f | sed 's/chrono_/chrono::/'`
- mv $f $newname
+for ns in chrono filesystem ranges views literals; do
+ for f in std_${ns}_*; do
+ newname=`echo $f | sed "s/std_${ns}_/std::${ns}::/"`
+ mv $f $newname
+ done
done
for f in *__debug_*; do
newname=`echo $f | sed 's/__debug_/__debug::/'`
@@ -413,11 +424,16 @@ for f in *_src_*; do
rm $f
done
+# Remove all internal implementation details?
+# rm std::_[A-Z]*.3 std::__detail*.3
+
+shopt -u nullglob
+
# Also, for some reason, typedefs don't get their own man pages. Sigh.
for f in ios streambuf istream ostream iostream stringbuf \
istringstream ostringstream stringstream filebuf ifstream \
- ofstream fstream string;
+ ofstream fstream string
do
echo ".so man3/std::basic_${f}.3" > std::${f}.3
echo ".so man3/std::basic_${f}.3" > std::w${f}.3