Просмотр исходного кода

Replace proposal list generation script with a link to a github query. (#842)

This aims to avoid merge conflicts when adding new proposals.
Richard Smith 4 лет назад
Родитель
Сommit
45ea240942

+ 0 - 7
.pre-commit-config.yaml

@@ -86,13 +86,6 @@ repos:
         language: python
         files: ^executable_semantics/syntax/parser.ypp$
         pass_filenames: false
-      - id: proposal-list
-        name: Update list of proposals
-        description: Updates the list of proposals in proposals/README.md
-        entry: proposals/scripts/update_proposal_list.py
-        language: python
-        files: ^proposals/(README|p.*)\.md$
-        pass_filenames: false
   # Formatters should be run late so that they can re-format any prior changes.
   - repo: https://github.com/psf/black
     rev: a8b4665e7d6eb945c47820adb1a3f8b006adce0c # frozen: 21.8b0

+ 7 - 59
proposals/README.md

@@ -6,6 +6,13 @@ Exceptions. See /LICENSE for license information.
 SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 -->
 
+## Proposal lists
+
+-   [All proposals](https://github.com/carbon-language/carbon-lang/pulls?q=is%3Apr+label%3Aproposal)
+-   [Accepted proposals](https://github.com/carbon-language/carbon-lang/pulls?q=is%3Apr+label%3Aproposal+label%3A%22decision%3A+accepted%22)
+
+## Directory structure
+
 This directory contains accepted proposals for the carbon-lang repository. For
 information about declined/deferred proposals, please view the proposal's
 original pull request.
@@ -16,62 +23,3 @@ request:
 -   `p####.md` will contain the main proposal text.
 -   `p####` may be present as an optional subdirectory for related files (for
     example, images).
-
-## Proposal list
-
-<!-- proposals -->
-<!-- Generated by ./scripts/update_proposal_list.py -->
-
--   [0024 - Generics goals](p0024.md)
--   [0029 - Linear, rebase, and pull-request GitHub workflow](p0029.md)
--   [0042 - Create code review guidelines](p0042.md)
--   [0044 - Proposal tracking](p0044.md)
--   [0051 - Goals](p0051.md)
--   [0063 - Criteria for Carbon to go public](p0063.md)
--   [0074 - Change comment/decision timelines in proposal process](p0074.md)
--   [0083 - In-progress design overview](p0083.md)
--   [0107 - Code and name organization](p0107.md)
--   [0113 - Add a C++ style guide](p0113.md)
--   [0120 - Add idiomatic code performance and developer-facing docs to goals](p0120.md)
--   [0142 - Unicode source files](p0142.md)
--   [0143 - Numeric literals](p0143.md)
--   [0149 - Change documentation style guide](p0149.md)
--   [0157 - Design direction for sum types](p0157.md)
--   [0162 - Basic Syntax](p0162.md)
--   [0175 - C++ interoperability goals](p0175.md)
--   [0179 - Create a toolchain team.](p0179.md)
--   [0196 - Language-level safety strategy](p0196.md)
--   [0198 - Comments](p0198.md)
--   [0199 - String literals](p0199.md)
--   [0253 - 2021 Roadmap](p0253.md)
--   [0257 - Initialization of memory and variables](p0257.md)
--   [0285 - if/else](p0285.md)
--   [0301 - Principle: Errors are values](p0301.md)
--   [0339 - `var` statement](p0339.md)
--   [0340 - while loops](p0340.md)
--   [0353 - `for` loops](p0353.md)
--   [0415 - Syntax: `return`](p0415.md)
--   [0426 - Governance & evolution revamp](p0426.md)
--   [0438 - Functions](p0438.md)
--   [0444 - GitHub Discussions](p0444.md)
--   [0447 - Generics terminology](p0447.md)
--   [0524 - Generics overview](p0524.md)
--   [0538 - `return` with no argument](p0538.md)
--   [0540 - Remove `Void`](p0540.md)
--   [0553 - Generics details part 1](p0553.md)
--   [0555 - Operator precedence](p0555.md)
--   [0561 - Basic classes: use cases, struct literals, struct types, and future work](p0561.md)
--   [0601 - Operator tokens](p0601.md)
--   [0618 - var ordering](p0618.md)
--   [0623 - Require braces](p0623.md)
--   [0646 - Low context-sensitivity principle](p0646.md)
--   [0676 - `:!` generic syntax](p0676.md)
--   [0680 - And, or, not](p0680.md)
--   [0722 - Nominal classes and methods](p0722.md)
--   [0731 - Generics details 2: adapters, associated types, parameterized interfaces](p0731.md)
--   [0752 - `api` file default-`public`](p0752.md)
--   [0777 - Inheritance](p0777.md)
--   [0820 - Implicit conversions](p0820.md)
--   [0829 - One way principle](p0829.md)
-
-<!-- endproposals -->

+ 0 - 26
proposals/scripts/BUILD

@@ -4,19 +4,6 @@
 
 load("@mypy_integration//:mypy.bzl", "mypy_test")
 
-py_library(
-    name = "proposal_list",
-    srcs = ["proposal_list.py"],
-)
-
-py_test(
-    name = "proposal_list_test",
-    srcs = ["proposal_list_test.py"],
-    data = ["//proposals:md_files"],
-    python_version = "PY3",
-    deps = [":proposal_list"],
-)
-
 py_binary(
     name = "new_proposal",
     srcs = ["new_proposal.py"],
@@ -36,16 +23,3 @@ mypy_test(
     include_imports = True,
     deps = [":new_proposal"],
 )
-
-# This is a directly runnable script, but should not be run via bazel.
-py_library(
-    name = "update_proposal_list",
-    srcs = ["update_proposal_list.py"],
-    deps = [":proposal_list"],
-)
-
-mypy_test(
-    name = "update_proposal_list_mypy_test",
-    include_imports = True,
-    deps = [":update_proposal_list"],
-)

+ 0 - 40
proposals/scripts/proposal_list.py

@@ -1,40 +0,0 @@
-"""Provides a list of proposal files."""
-
-__copyright__ = """
-Part of the Carbon Language project, under the Apache License v2.0 with LLVM
-Exceptions. See /LICENSE for license information.
-SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-"""
-
-import os
-import re
-import sys
-from typing import List, Tuple
-
-
-def get_title(parent_dir: str, entry: str) -> str:
-    """Returns the title from the requested file."""
-    path = os.path.join(parent_dir, entry)
-    with open(path) as md:
-        titles = [t for t in md.readlines() if t.startswith("# ")]
-        if not titles:
-            sys.exit("%r is missing a title." % path)
-        return titles[0][2:-1]
-
-
-def get_path() -> str:
-    return os.path.realpath(os.path.join(os.path.dirname(__file__), ".."))
-
-
-def get_list(proposals_path: str) -> List[Tuple[str, str]]:
-    proposals = []
-    proposals_list = os.listdir(proposals_path)
-    proposals_list.sort()
-    for f in proposals_list:
-        match = re.match(r"^p([0-9]{4})\.md$", f)
-        if not match:
-            continue
-        number = match[1]
-        title = get_title(proposals_path, f)
-        proposals.append(("%s - %s" % (number, title), f))
-    return proposals

+ 0 - 35
proposals/scripts/proposal_list_test.py

@@ -1,35 +0,0 @@
-"""Tests for proposal_list.py."""
-
-__copyright__ = """
-Part of the Carbon Language project, under the Apache License v2.0 with LLVM
-Exceptions. See /LICENSE for license information.
-SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-"""
-
-import unittest
-
-from proposals.scripts import proposal_list
-
-
-class TestProposal(unittest.TestCase):
-    def test_get_path(self):
-        proposals_path = proposal_list.get_path()
-        p = proposal_list.get_list(proposals_path)
-        self.assertEqual(
-            p[0],
-            (
-                "0024 - Generics goals",
-                "p0024.md",
-            ),
-        )
-        self.assertEqual(
-            p[1],
-            (
-                "0029 - Linear, rebase, and pull-request GitHub workflow",
-                "p0029.md",
-            ),
-        )
-
-
-if __name__ == "__main__":
-    unittest.main()

+ 0 - 56
proposals/scripts/update_proposal_list.py

@@ -1,56 +0,0 @@
-#!/usr/bin/env python3
-
-"""Updates the list of proposals in proposals/README.md."""
-
-__copyright__ = """
-Part of the Carbon Language project, under the Apache License v2.0 with LLVM
-Exceptions. See /LICENSE for license information.
-SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-"""
-
-import io
-import os
-import importlib.util
-import re
-import sys
-
-# Do some extra work to support direct runs.
-try:
-    from proposals.scripts import proposal_list
-except ImportError:
-    proposal_list_spec = importlib.util.spec_from_file_location(
-        "proposal_list",
-        os.path.join(os.path.dirname(__file__), "proposal_list.py"),
-    )
-    proposal_list = importlib.util.module_from_spec(proposal_list_spec)
-    proposal_list_spec.loader.exec_module(proposal_list)  # type: ignore
-
-if __name__ == "__main__":
-    proposals_path = proposal_list.get_path()
-
-    with io.StringIO() as out:
-        out.write("<!-- Generated by ./scripts/update_proposal_list.py -->\n\n")
-        results = out.getvalue()
-        for title, filename in proposal_list.get_list(proposals_path):
-            out.write("-   [%s](%s)\n" % (title, filename))
-        toc = out.getvalue()
-
-    # Replace the README content if needed.
-    readme_path = os.path.join(proposals_path, "README.md")
-    with open(readme_path) as f:
-        old_content = f.read()
-    proposals_re = re.compile(
-        r"(.*<!-- proposals -->)(?:.*)(<!-- endproposals -->)",
-        re.DOTALL | re.MULTILINE,
-    )
-    if not proposals_re.match(old_content):
-        print(
-            "ERROR: proposals/README.md is missing the <!-- proposals --> ... "
-            "<!-- endproposals --> marker."
-        )
-        sys.exit(1)
-    new_content = proposals_re.sub(r"\1\n%s\n\2" % toc, old_content)
-    if old_content != new_content:
-        print("Updating proposals/README.md")
-        with open(readme_path, "w") as f:
-            f.write(new_content)