Skip to content

Commit edc22ae

Browse files
authored
CXX-3063 deploy only the latest API docs during a release (#1169)
* releasing: add warning for `git clean -dfx` command * perl: fix syntax highlighting errors in etc/generate-apidocs-from-tag.pl * releasing: speed up clone of gh-pages repo during deployment * releasing: use local build/tmp-repo instead of system /tmp for deployment * CXX-3063 require Doxygen version 1.9.1 * CXX-3063 commit ONLY latest API docs to gh-pages during release
1 parent 2b85876 commit edc22ae

File tree

6 files changed

+62
-91
lines changed

6 files changed

+62
-91
lines changed

CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -309,14 +309,14 @@ add_custom_target(doxygen-current
309309
VERBATIM
310310
)
311311

312-
add_custom_target(doxygen-all
312+
add_custom_target(doxygen-latest
313313
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
314-
COMMAND etc/generate-all-apidocs.pl
314+
COMMAND etc/generate-latest-apidocs.pl
315315
VERBATIM
316316
)
317317

318318
add_custom_target(doxygen-deploy
319-
DEPENDS doxygen-all
319+
DEPENDS doxygen-latest
320320
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
321321
COMMAND etc/deploy-to-ghpages.pl --doxygen [email protected]:mongodb/mongo-cxx-driver
322322
VERBATIM

etc/deploy-to-ghpages.pl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ sub _doxygen_rsync {
3737
my $tmpdir = shift;
3838
my @filters = ( '- /current', '- /mongocxx-v3', '- /legacy-v1' );
3939
_try_run(
40-
qw{rsync -Cavz --delete},
40+
qw{rsync -Cavz},
4141
( map { ; '--filter' => $_ } @filters ),
4242
"build/docs/api/", "$tmpdir/api/"
4343
);
@@ -56,11 +56,12 @@ sub main {
5656
my $orig_dir = getcwd();
5757

5858
# Create tempdir to store copy of repo.
59-
my $tmp = tempdir( DIR => "/tmp", CLEANUP => 1 );
59+
_try_run("mkdir", "-p", "build/tmp-repo");
60+
my $tmp = tempdir( DIR => "build/tmp-repo", CLEANUP => 1 );
6061
my $tmpdir = realpath("$tmp");
6162

6263
# Clone current repo to tempdir and checkout gh-pages branch.
63-
_try_run( qw/git clone/, $source_repo, $tmpdir );
64+
_try_run( qw/git clone --filter=blob:none/, $source_repo, $tmpdir );
6465
{
6566
my $guard = _pushd($tmpdir);
6667
_try_run(qw/git checkout gh-pages/);
@@ -104,4 +105,3 @@ sub DESTROY {
104105
my $self = shift;
105106
$self->{demolish}->() if $self->{demolish};
106107
}
107-

etc/generate-all-apidocs.pl

Lines changed: 0 additions & 77 deletions
This file was deleted.

etc/generate-apidocs-from-tag.pl

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@
99
use File::Temp qw/tempdir/;
1010
use List::Util qw/first/;
1111

12+
# The required Doxygen version.
13+
# The generated results are sensitive to the release version.
14+
our $doxygen_version_required = "1.9.1";
15+
16+
# Allow specifying a custom Doxygen binary via the `$DOXYGEN_BINARY` environment variable.
17+
our $doxygen_binary = $ENV{DOXYGEN_BINARY} || "doxygen";
18+
1219
# system() wrapper to die with an error if a command fails.
1320
sub _try_run {
1421
my @command = @_;
@@ -74,7 +81,7 @@ sub _parse_doxygen_config {
7481
next if substr($line,0,1) eq '#';
7582
next unless $line =~ /\S.*=/;
7683
# Join lines ending in backslash.
77-
while ( $line =~ s{\\\n\z}{} ) {
84+
while ( $line =~ s/\\\n\z// ) {
7885
$line .= " " . <$fh>;
7986
}
8087
# Save full line under the assigned key
@@ -84,6 +91,17 @@ sub _parse_doxygen_config {
8491
return \%config;
8592
}
8693

94+
# Enforce a compatible Doxygen version.
95+
sub _check_doxygen_version {
96+
die "Failed to parse Doxygen version from output of `$doxygen_binary -v`"
97+
unless `$doxygen_binary -v` =~ /^(\d+\.\d+\.\d+).*$/;
98+
99+
my $doxygen_version = $1; # Strip unneeded content.
100+
101+
die "Detected Doxygen version $doxygen_version does not match required version $doxygen_version_required"
102+
unless $doxygen_version =~ /^$doxygen_version_required/
103+
}
104+
87105
sub main {
88106
my $gitref = shift @ARGV;
89107

@@ -134,8 +152,11 @@ sub main {
134152
qq[HTML_EXTRA_STYLESHEET = "$orig_dir/etc/doxygen-extra.css"\n],
135153
);
136154

155+
# Ensure up-to-date Doxygen version.
156+
_check_doxygen_version();
157+
137158
# Run doxygen
138-
_try_run('doxygen', "$tmpdir/Doxyfile");
159+
_try_run("$doxygen_binary", "$tmpdir/Doxyfile");
139160
}
140161

141162
main();
@@ -152,4 +173,3 @@ sub DESTROY {
152173
my $self = shift;
153174
$self->{demolish}->() if $self->{demolish};
154175
}
155-

etc/generate-latest-apidocs.pl

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env perl
2+
use v5.14;
3+
use strict;
4+
use warnings;
5+
use utf8;
6+
use open qw/:std :utf8/;
7+
8+
# system() wrapper to die with an error if a command fails.
9+
sub _try_run {
10+
my @command = @_;
11+
say "> Running: @command";
12+
system(@command);
13+
die "Error running '@command" if $?;
14+
}
15+
16+
my $LATEST_DOC_TAG = "r3.10.2";
17+
18+
sub main {
19+
_try_run("etc/generate-apidocs-from-tag.pl", $LATEST_DOC_TAG);
20+
}
21+
22+
main();

etc/releasing.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,7 @@ Example (using Jira syntax formatting):
552552
> [!NOTE]
553553
> Some of these commands may take a while to complete.
554554
555-
Add the new release to the `@DOC_TAGS` array in `etc/generate-all-apidocs.pl`.
555+
Set `$LATEST_DOC_TAG` in `etc/generate-latest-apidocs.pl` to the latest release tag.
556556

557557
Commit these changes to the `post-release-changes` branch:
558558

@@ -566,24 +566,30 @@ Ensure `doxygen` and `hugo` are locally installed and up-to-date.
566566
command -V doxygen hugo
567567
```
568568

569+
> [!IMPORTANT]
570+
> The required Doxygen version is defined in `etc/generate-apidocs-from-tag.pl` as `$doxygen_version_required`. If not already present, download the required version from [Doxygen Releases](https://www.doxygen.nl/download.html). Use the `DOXYGEN_BINARY` environment variable to override the default `doxygen` command with a path to a specific Doxygen binary.
571+
569572
Run `git clean -dfx` to restore the repository to a clean state.
570573

574+
> [!WARNING]
575+
> Do NOT run `git clean -dfx` in your local development repository, as it may delete your local development files present in the repository (even if excluded)! Only run this in the command in the separate repository being used for this release!
576+
571577
Configure CMake using `build` as the binary directory. Leave all other configuration variables as their default.
572578

573579
```bash
574580
cmake -S . -B build
575581
```
576582

577-
Test generating Hugo docs locally by building the `docs` target:
583+
Test generating Hugo and Doxygen docs locally by building the `docs` target (this command DOES NOT check for the required Doxygen version):
578584

579585
```bash
580586
cmake --build build --target docs
581587
```
582588

583-
Test generating Doxygen docs by building the `doxygen-all` target:
589+
Test generating the latest versioned Doxygen docs by building the `doxygen-latest` target (this command DOES checks for the required Doxygen version):
584590

585591
```bash
586-
cmake --build build --target doxygen-all
592+
cmake --build build --target doxygen-latest
587593
```
588594

589595
Verify that the `build/docs/api/mongocxx-X.Y.Z` directory is present and populated.

0 commit comments

Comments
 (0)