Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp4943225rwr; Sun, 30 Apr 2023 19:24:56 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4mOkb2PXudhvDjMQ7lcRWZoOCO2RpSDRb7+m19lbQyDDGem4lMKhOKntciMFDYKk3hpJO3 X-Received: by 2002:a05:6a20:d69a:b0:ee:2bc1:6e01 with SMTP id it26-20020a056a20d69a00b000ee2bc16e01mr12906065pzb.24.1682907896263; Sun, 30 Apr 2023 19:24:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682907896; cv=none; d=google.com; s=arc-20160816; b=Y+kw3e/FO1ML7/EJW1RshwT0ZYFTAo/CMBaYJBsBY3AuFyszhPKaGCT1O3YuUOdlVu p49H9sv0/36SWiBNIf3ZxV9HZWIp6uAP1LEjl9pc64UF7qoxFpyK/Ras/GIivYAFAngT mcFwEoBKb2Ypvza/2hC81OwINhb2L84qVfH3kMilOWya7TzRr8V2t1CnPzQixg6cE3Al rSjNK4aQPcQRO60wHTsGsOux4rSpFEL8bJjeny8azu89fAWnbd/Zmn+3yCbqcIpq8I6f 3/rLY8EkCDT+o0U8e8bEqGGuGzcBTruaV6AljhMBUUGUpl4Wh3K6TLcJxH2YRbVr8qyf 5jng== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bs9-20020a632809000000b0051b685209d5si26280674pgb.460.2023.04.30.19.24.41; Sun, 30 Apr 2023 19:24:56 -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 S231779AbjEACO6 (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 Content-Transfer-Encoding: 8bit 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 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 -- 2.40.0