From: Ferdinand Vanmaele Date: Wed, 11 Sep 2019 12:46:28 +0000 (+0200) Subject: doxygen: rewrite set_canonical_doxygen.py in Perl X-Git-Tag: v9.2.0-rc1~1000^2~2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2e098049bd5ec85a5d2bdbe15b7855a6044f9210;p=dealii.git doxygen: rewrite set_canonical_doxygen.py in Perl Fixes issue #8735 --- diff --git a/doc/doxygen/CMakeLists.txt b/doc/doxygen/CMakeLists.txt index e611b3f705..d47b0bab85 100644 --- a/doc/doxygen/CMakeLists.txt +++ b/doc/doxygen/CMakeLists.txt @@ -284,8 +284,9 @@ ADD_CUSTOM_COMMAND( ${CMAKE_CURRENT_BINARY_DIR}/options.dox > ${CMAKE_BINARY_DIR}/doxygen.log 2>&1 # *pssst* || ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/doxygen.log ${CMAKE_BINARY_DIR}/doxygen.err - COMMAND - ${CMAKE_CURRENT_SOURCE_DIR}/scripts/set_canonical_doxygen.py + COMMAND ${PERL_EXECUTABLE} + ARGS + ${CMAKE_CURRENT_SOURCE_DIR}/scripts/set_canonical_doxygen.pl WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} DEPENDS tutorial diff --git a/doc/doxygen/scripts/set_canonical_doxygen.pl b/doc/doxygen/scripts/set_canonical_doxygen.pl new file mode 100644 index 0000000000..51af255142 --- /dev/null +++ b/doc/doxygen/scripts/set_canonical_doxygen.pl @@ -0,0 +1,93 @@ +## --------------------------------------------------------------------- +## +## Copyright (C) 2019 by the deal.II authors +## +## This file is part of the deal.II library. +## +## The deal.II library is free software; you can use it, redistribute +## it, and/or modify it under the terms of the GNU Lesser General +## Public License as published by the Free Software Foundation; either +## version 2.1 of the License, or (at your option) any later version. +## The full text of the license can be found in the file LICENSE at +## the top level of the deal.II distribution. +## +## --------------------------------------------------------------------- + +# This script sets the canonical webpage for all the webpages of the +# doxygen documentation. For more information see +# https://en.wikipedia.org/wiki/Canonical_link_element +# +# This script is invoked by CMake. To add the canonical link to the webpages of +# the deal.ii repository you can use the script +# contrib/utilities/set_canonical_webpages.py + +use strict; +use warnings; + +use File::Find qw(find); + +my @html; +my $link_start = ') + { + if (index($line, ') + { + $new_text_data .= $line; + + # Do not add canonical link twice + if ( ! $canonical_link_added and index($line, '') != -1) + { + die unless substr($filename, 0, 2) eq "./"; + + $new_text_data .= $link_start . substr($filename, 2) . '" />' . "\n"; + $canonical_link_added = 1; + } + } + } + + if (length($new_text_data) > 0) + { + # Truncate the file and write the new text + seek($file_handle, 0, 0) + or die "Could not seek $filename: $!"; + print $file_handle $new_text_data; + + truncate($file_handle, tell($file_handle)) + or die "Could not truncate $filename: $!"; + close($file_handle) + or die "Could not close $filename: $!"; + } +} diff --git a/doc/doxygen/scripts/set_canonical_doxygen.py b/doc/doxygen/scripts/set_canonical_doxygen.py deleted file mode 100755 index 4d6d8b3bda..0000000000 --- a/doc/doxygen/scripts/set_canonical_doxygen.py +++ /dev/null @@ -1,58 +0,0 @@ -#!/usr/bin/env python -## --------------------------------------------------------------------- -## -## Copyright (C) 2019 by the deal.II authors -## -## This file is part of the deal.II library. -## -## The deal.II library is free software; you can use it, redistribute -## it, and/or modify it under the terms of the GNU Lesser General -## Public License as published by the Free Software Foundation; either -## version 2.1 of the License, or (at your option) any later version. -## The full text of the license can be found in the file LICENSE at -## the top level of the deal.II distribution. -## -## --------------------------------------------------------------------- - -# This script sets the canonical webpage for all the webpages of the -# doxygen documentation. For more information see -# https://en.wikipedia.org/wiki/Canonical_link_element -# -# This script is invoked by CMake. To add the canonical link to the webpages of -# the deal.ii repository you can use the script -# contrib/utilities/set_canonical_webpages.py - -import os - -LINK_START = ('' in line: - assert filename[:2] == "./" - new_text_data += LINK_START + filename[2:] + '" />\n' - canonical_link_added = True - if new_text_data: - # Truncate the file and write the new text - with open(filename, 'w+') as file_handle: - file_handle.write(new_text_data)