[(pushed)] sphinx: update diagnostics URLs

Message ID 4b3c5344-171c-783e-e485-611223baf5bc@suse.cz
State Accepted
Headers
Series [(pushed)] sphinx: update diagnostics URLs |

Checks

Context Check Description
snail/gcc-patch-check success Github commit url

Commit Message

Martin Liška Nov. 9, 2022, 12:12 p.m. UTC
  For the future, we'll use https://pypi.org/project/sphinx-redirect-by-id/
which will allow links like

https://gcc.gnu.org/onlinedocs/gcc/redirect.html?q=cmdoption-Wfoo

but for now, let's use the proper landing pages.

Martin

gcc/ChangeLog:

	* opts.cc (get_option_html_page): Port to sphinx URLs.
	(get_option_url): Likewise.
	(test_get_option_html_page): Likewise.
---
 gcc/opts.cc | 26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)
  

Comments

Richard Biener Nov. 9, 2022, 1 p.m. UTC | #1
On Wed, Nov 9, 2022 at 1:12 PM Martin Liška <mliska@suse.cz> wrote:
>
> For the future, we'll use https://pypi.org/project/sphinx-redirect-by-id/
> which will allow links like
>
> https://gcc.gnu.org/onlinedocs/gcc/redirect.html?q=cmdoption-Wfoo
>
> but for now, let's use the proper landing pages.

Do we need a redirect at the old location?

> Martin
>
> gcc/ChangeLog:
>
>         * opts.cc (get_option_html_page): Port to sphinx URLs.
>         (get_option_url): Likewise.
>         (test_get_option_html_page): Likewise.
> ---
>  gcc/opts.cc | 26 ++++++++++++++------------
>  1 file changed, 14 insertions(+), 12 deletions(-)
>
> diff --git a/gcc/opts.cc b/gcc/opts.cc
> index 3797784c865..c00887ae76e 100644
> --- a/gcc/opts.cc
> +++ b/gcc/opts.cc
> @@ -3608,11 +3608,11 @@ get_option_html_page (int option_index)
>
>    /* Analyzer options are on their own page.  */
>    if (strstr (cl_opt->opt_text, "analyzer-"))
> -    return "gcc/Static-Analyzer-Options.html";
> +    return "gcc/gcc-command-options/options-that-control-static-analysis.html";
>
>    /* Handle -flto= option.  */
>    if (strstr (cl_opt->opt_text, "flto"))
> -    return "gcc/Optimize-Options.html";
> +    return "gcc/gcc-command-options/options-that-control-optimization.html";
>
>  #ifdef CL_Fortran
>    if ((cl_opt->flags & CL_Fortran) != 0
> @@ -3623,10 +3623,11 @@ get_option_html_page (int option_index)
>        && (cl_opt->flags & CL_CXX) == 0
>  #endif
>       )
> -    return "gfortran/Error-and-Warning-Options.html";
> +    return ("gfortran/gnu-fortran-command-options/"
> +           "options-to-request-or-suppress-errors-and-warnings.html");
>  #endif
>
> -  return "gcc/Warning-Options.html";
> +  return "gcc/gcc-command-options/options-to-request-or-suppress-warnings.html";
>  }
>
>  /* Return malloced memory for a URL describing the option OPTION_INDEX
> @@ -3645,11 +3646,8 @@ get_option_url (diagnostic_context *, int option_index)
>                       "gcc/Warning-Options.html".  */
>                    get_option_html_page (option_index),
>
> -                  /* Expect an anchor of the form "index-Wfoo" e.g.
> -                     <a name="index-Wformat"></a>, and thus an id within
> -                     the URL of "#index-Wformat".  */
> -                  "#index", cl_options[option_index].opt_text,
> -                  NULL);
> +                  /* Expect an anchor of the form "cmdoption-Wfoo".  */
> +                  "#cmdoption", cl_options[option_index].opt_text, NULL);
>    else
>      return NULL;
>  }
> @@ -3786,12 +3784,16 @@ namespace selftest {
>  static void
>  test_get_option_html_page ()
>  {
> -  ASSERT_STREQ (get_option_html_page (OPT_Wcpp), "gcc/Warning-Options.html");
> +  ASSERT_STREQ (get_option_html_page (OPT_Wcpp),
> +               "gcc/gcc-command-options/"
> +               "options-to-request-or-suppress-warnings.html");
>    ASSERT_STREQ (get_option_html_page (OPT_Wanalyzer_double_free),
> -            "gcc/Static-Analyzer-Options.html");
> +               "gcc/gcc-command-options/"
> +               "options-that-control-static-analysis.html");
>  #ifdef CL_Fortran
>    ASSERT_STREQ (get_option_html_page (OPT_Wline_truncation),
> -               "gfortran/Error-and-Warning-Options.html");
> +               "gfortran/gnu-fortran-command-options/"
> +               "options-to-request-or-suppress-errors-and-warnings.html");
>  #endif
>  }
>
> --
> 2.38.0
>
  
Martin Liška Nov. 9, 2022, 1:07 p.m. UTC | #2
On 11/9/22 14:00, Richard Biener wrote:
> Do we need a redirect at the old location?

Well, what's not working are older gcc releases that still point to "master" branch
documentation:

gcc --version
gcc (SUSE Linux) 12.2.1 20221020 [revision 0aaef83351473e8f4eb774f8f999bbe87a4866d7]
...
https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wunused-parameter

these should point ideally to:
https://gcc.gnu.org/onlinedocs/gcc-12.2.0/gcc/Warning-Options.html#index-Wunused-parameter

anyway, we can provider redirect for these, I'll ask Gerald.

Martin
  
Richard Biener Nov. 9, 2022, 1:15 p.m. UTC | #3
On Wed, Nov 9, 2022 at 2:07 PM Martin Liška <mliska@suse.cz> wrote:
>
> On 11/9/22 14:00, Richard Biener wrote:
> > Do we need a redirect at the old location?
>
> Well, what's not working are older gcc releases that still point to "master" branch
> documentation:
>
> gcc --version
> gcc (SUSE Linux) 12.2.1 20221020 [revision 0aaef83351473e8f4eb774f8f999bbe87a4866d7]
> ...
> https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wunused-parameter
>
> these should point ideally to:
> https://gcc.gnu.org/onlinedocs/gcc-12.2.0/gcc/Warning-Options.html#index-Wunused-parameter

I suppose we might want to point to the "latest" 12 version, so have a
gcc-12/ link and use that?
And have a releasing.html entry saying to adjust those URLs in source
to point to the new
version instead of trunk?

> anyway, we can provider redirect for these, I'll ask Gerald.

Thanks

> Martin
  

Patch

diff --git a/gcc/opts.cc b/gcc/opts.cc
index 3797784c865..c00887ae76e 100644
--- a/gcc/opts.cc
+++ b/gcc/opts.cc
@@ -3608,11 +3608,11 @@  get_option_html_page (int option_index)
 
   /* Analyzer options are on their own page.  */
   if (strstr (cl_opt->opt_text, "analyzer-"))
-    return "gcc/Static-Analyzer-Options.html";
+    return "gcc/gcc-command-options/options-that-control-static-analysis.html";
 
   /* Handle -flto= option.  */
   if (strstr (cl_opt->opt_text, "flto"))
-    return "gcc/Optimize-Options.html";
+    return "gcc/gcc-command-options/options-that-control-optimization.html";
 
 #ifdef CL_Fortran
   if ((cl_opt->flags & CL_Fortran) != 0
@@ -3623,10 +3623,11 @@  get_option_html_page (int option_index)
       && (cl_opt->flags & CL_CXX) == 0
 #endif
      )
-    return "gfortran/Error-and-Warning-Options.html";
+    return ("gfortran/gnu-fortran-command-options/"
+	    "options-to-request-or-suppress-errors-and-warnings.html");
 #endif
 
-  return "gcc/Warning-Options.html";
+  return "gcc/gcc-command-options/options-to-request-or-suppress-warnings.html";
 }
 
 /* Return malloced memory for a URL describing the option OPTION_INDEX
@@ -3645,11 +3646,8 @@  get_option_url (diagnostic_context *, int option_index)
 		      "gcc/Warning-Options.html".  */
 		   get_option_html_page (option_index),
 
-		   /* Expect an anchor of the form "index-Wfoo" e.g.
-		      <a name="index-Wformat"></a>, and thus an id within
-		      the URL of "#index-Wformat".  */
-		   "#index", cl_options[option_index].opt_text,
-		   NULL);
+		   /* Expect an anchor of the form "cmdoption-Wfoo".  */
+		   "#cmdoption", cl_options[option_index].opt_text, NULL);
   else
     return NULL;
 }
@@ -3786,12 +3784,16 @@  namespace selftest {
 static void
 test_get_option_html_page ()
 {
-  ASSERT_STREQ (get_option_html_page (OPT_Wcpp), "gcc/Warning-Options.html");
+  ASSERT_STREQ (get_option_html_page (OPT_Wcpp),
+		"gcc/gcc-command-options/"
+		"options-to-request-or-suppress-warnings.html");
   ASSERT_STREQ (get_option_html_page (OPT_Wanalyzer_double_free),
-	     "gcc/Static-Analyzer-Options.html");
+		"gcc/gcc-command-options/"
+		"options-that-control-static-analysis.html");
 #ifdef CL_Fortran
   ASSERT_STREQ (get_option_html_page (OPT_Wline_truncation),
-		"gfortran/Error-and-Warning-Options.html");
+		"gfortran/gnu-fortran-command-options/"
+		"options-to-request-or-suppress-errors-and-warnings.html");
 #endif
 }