From patchwork Mon May 1 02:13:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Costa Shulyupin X-Patchwork-Id: 88965 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2441656vqo; Sun, 30 Apr 2023 19:57:48 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7kA4OgI/+jIxDSwpV2e2S1SaosBVFdxXDyvvnyhg4isTN/i/vpDr/w8o/gicLW1qSvEbHd X-Received: by 2002:a17:902:e849:b0:1a9:8ff5:af43 with SMTP id t9-20020a170902e84900b001a98ff5af43mr14660919plg.18.1682909868557; Sun, 30 Apr 2023 19:57:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682909868; cv=none; d=google.com; s=arc-20160816; b=ceoThyEv0yCerbICMMatXRpBHUzkXN98T0hHFnwfFFpGkqfO8VxbvtvDLnZ8qX+6M3 1+opY7wr8dmc4DzdIAGLlKRzaXDedGM0JY9RqxoPcq45md6cGNdZeMISZQXY+SUNFovY zTGqGjOypXMWSbNZSCYSVfWuXgxpgoWAuh6FOeXmQ6N6zUNP1Jcyjv0Y6OL6O3622MQg HMpCMGRg9pvvSFPrjJtgAWbjkhF3Itjca4vy47JJT+KkhUFQSDcfh66j2LOCz4yHFSOI ISB6zGoHgbi+1IZvQK+6cAVf2LWcK2Qq6JwoFc9f7DbqsYTV6LY4J1bZc0YdMltIYP6u rrBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=dF2Oq+4K4N5QrRxu/ofhiyU4ka4upW1zrADy8lB3cuE=; b=xjRzEYOnjPcbW+G3ekG4KNbFeGC+6XlYs4QPTWhRRFRNmxcd1vq2wPkXYMMTg5HNjk nKfag1yKNC5m/xKb0+f248M/ihphNRsgVPMQVCLQ/NlZckMVf6hdC8kQwa8m7qfYkG1z u88JqWwDzXIQEnSCAn/0w7cibosWofFBZSaYXA2OXuhY4fHA7bCFcEV9noKLT9VJ8HVz +DcrSFGhP+Ggb5+Xe7NkaXukwTCmAxpxflYsL5es9vzAio5ckWSq8QFRj/ZwrZzPBJcG bT8ggYS5iynvtYtCHsC/a9bYpdcTHbru5rvr5FiqSLsheDn7xSXpvziKINEl9HqriUM8 cd9w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u16-20020a63d350000000b0051410c79705si28012132pgi.867.2023.04.30.19.57.27; Sun, 30 Apr 2023 19:57:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231803AbjEACO6 (ORCPT + 99 others); Sun, 30 Apr 2023 22:14:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43266 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229531AbjEACO5 (ORCPT ); Sun, 30 Apr 2023 22:14:57 -0400 Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CD42EE4E; Sun, 30 Apr 2023 19:14:55 -0700 (PDT) Received: by mail-wr1-f43.google.com with SMTP id ffacd0b85a97d-2f833bda191so1105640f8f.1; Sun, 30 Apr 2023 19:14:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682907294; x=1685499294; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=dF2Oq+4K4N5QrRxu/ofhiyU4ka4upW1zrADy8lB3cuE=; b=PKKfCuDg2FFpsyKPwverRrurvazHKM/00biQQV+UOTz9IluBCGu9EPNmEhedbGh9sa a3+WnulHyyVbV16ByjohZBR1ZoTlqyt37pPxyfYyTq25Vp9fxcF1B6SyzeF54uSlV5hL 2m8EPPgkPVvU++Ma3BPINyDqABAVy40i0ZkQYQAwZ++qrUJ84mjLk/g8SGiRx+V8Mq+T 3qXuUBe/zzHvVrgF86aFBe1sMZnW7W8pu7qK4hxNm/KHQAwXdh1Wzkxyt8d8fWq2Hix2 gTB6Y7MxPuC44qzzt1RhDrvyPQIX+X1RFPW0/NQUitbSIj2W60Ygz0RaDOqY5PoE3aGN zKzQ== X-Gm-Message-State: AC+VfDzITdLYa1BDp0Fhup21DZLWJ1N/3wEVTqijwFq/uvBzFLisubGN lE2C6dppHMRglXVdpUbNnKM= X-Received: by 2002:a5d:5186:0:b0:306:2b5f:8d0a with SMTP id k6-20020a5d5186000000b003062b5f8d0amr2029597wrv.56.1682907294075; Sun, 30 Apr 2023 19:14:54 -0700 (PDT) Received: from costa-tp.bos2.lab ([2a00:a040:1a3:c11b:3ae6:1732:e587:a81f]) by smtp.gmail.com with ESMTPSA id bl13-20020adfe24d000000b003062d3daf79sm1568660wrb.107.2023.04.30.19.14.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 Apr 2023 19:14:53 -0700 (PDT) From: Costa Shulyupin To: Jonathan Corbet , Mauro Carvalho Chehab , linux-doc@vger.kernel.org Cc: Costa Shulyupin , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v2] docs: automatic redirects for moved pages Date: Mon, 1 May 2023 05:13:36 +0300 Message-Id: <20230501021338.182770-1-costa.shul@redhat.com> X-Mailer: git-send-email 2.40.0 MIME-Version: 1.0 X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764658898030436073?= X-GMAIL-MSGID: =?utf-8?q?1764658898030436073?= Problems: - The documentation is not well-organized - Relocating pages disrupts external links to the documentation and causes confusion for users Benefits: - Users can easily access relocated pages from external resources - Using redirects frees up options for reorganizing the documentation The solution: - To prevent the need for ongoing maintenance, extract renames from git log since specified age - Input the renames into sphinx_reredirects module Signed-off-by: Costa Shulyupin --- Changes: - added the extraction of renames from Git. --- Documentation/Makefile | 8 +++++++- Documentation/conf.py | 17 ++++++++++++++++- Documentation/sphinx/requirements.txt | 1 + 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/Documentation/Makefile b/Documentation/Makefile index 023fa658a0a8..fae385cf4d6d 100644 --- a/Documentation/Makefile +++ b/Documentation/Makefile @@ -91,10 +91,16 @@ quiet_cmd_sphinx = SPHINX $@ --> file://$(abspath $(BUILDDIR)/$3/$4) cp $(if $(patsubst /%,,$(DOCS_CSS)),$(abspath $(srctree)/$(DOCS_CSS)),$(DOCS_CSS)) $(BUILDDIR)/$3/_static/; \ fi -htmldocs: +htmldocs: Documentation/redirects @$(srctree)/scripts/sphinx-pre-install --version-check @+$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,html,$(var),,$(var))) +Documentation/redirects: $(srctree)/**/*.rst + git log --since="5 years ago" \ + --name-status --find-renames=30 --diff-filter=R \ + $(srctree)/Documentation/ \ + | grep ^R | cut -f2,3 > $@ + texinfodocs: @$(srctree)/scripts/sphinx-pre-install --version-check @+$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,texinfo,$(var),texinfo,$(var))) diff --git a/Documentation/conf.py b/Documentation/conf.py index 37314afd1ac8..16c5036992a0 100644 --- a/Documentation/conf.py +++ b/Documentation/conf.py @@ -16,6 +16,7 @@ import sys import os import sphinx import shutil +import re # helper # ------ @@ -55,7 +56,21 @@ needs_sphinx = '1.7' extensions = ['kerneldoc', 'rstFlatTable', 'kernel_include', 'kfigure', 'sphinx.ext.ifconfig', 'automarkup', 'maintainers_include', 'sphinx.ext.autosectionlabel', - 'kernel_abi', 'kernel_feat'] + 'kernel_abi', 'kernel_feat', + 'sphinx_reredirects', +] + +redirects = dict() + +with open('redirects', 'r') as f: + for line in f: + p = r'Documentation/(.*)\.rst' + m = re.search(f'{p}\t{p}', line) + if not m or os.path.isfile(line.split()[0]): + continue + redirects[m.group(1) + '.html'] = os.path.relpath(m.group(2), + os.path.dirname(m.group(1))) + '.html' + if major >= 3: if (major > 3) or (minor > 0 or patch >= 2): diff --git a/Documentation/sphinx/requirements.txt b/Documentation/sphinx/requirements.txt index 335b53df35e2..0b067e985edb 100644 --- a/Documentation/sphinx/requirements.txt +++ b/Documentation/sphinx/requirements.txt @@ -1,3 +1,4 @@ # jinja2>=3.1 is not compatible with Sphinx<4.0 jinja2<3.1 Sphinx==2.4.4 +sphinx_reredirects