Skip to content

Commit

Permalink
Merge pull request #2 from tristanlatr/more-projects
Browse files Browse the repository at this point in the history
More projects
  • Loading branch information
tristanlatr authored Nov 3, 2023
2 parents 14a3cc6 + 1749b2d commit 5c75a3e
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 47 deletions.
2 changes: 1 addition & 1 deletion pydoctor_primer/globals.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def parse_options(argv: list[str]) -> _Args:

proj_group = parser.add_argument_group("project selection")
proj_group.add_argument(
"-k", "--project-selector", help="regex to filter projects (matches against location)"
"-k", "--project-selector", help="fnmatch pattern to filter projects (matches against location)"
)
proj_group.add_argument(
"-p",
Expand Down
5 changes: 3 additions & 2 deletions pydoctor_primer/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from dataclasses import replace
from pathlib import Path
from typing import Awaitable, Iterator, TypeVar
import fnmatch

from pydoctor_primer.git_utils import (
RevisionLike,
Expand Down Expand Up @@ -67,7 +68,7 @@ def select_projects() -> list[Project]:
)
if ARGS.project_selector:
project_iter = iter(
p for p in project_iter if re.search(ARGS.project_selector, p.location, flags=re.I)
p for p in project_iter if fnmatch.fnmatch(p.location, ARGS.project_selector)
)
if ARGS.expected_success:
project_iter = (p for p in project_iter if p.expected_success)
Expand Down Expand Up @@ -180,7 +181,7 @@ async def bisect() -> None:
assert repo_dir.is_dir()

projects = select_projects()
await asyncio.wait([project.setup() for project in projects])
await asyncio.wait([asyncio.Task(project.setup()) for project in projects])

async def run_wrapper(project: Project) -> tuple[str, TypeCheckResult]:
return project.name, (await project.run_pydoctor(str(exe)))
Expand Down
129 changes: 85 additions & 44 deletions pydoctor_primer/projects.py
Original file line number Diff line number Diff line change
@@ -1,62 +1,103 @@
from __future__ import annotations

import difflib
import subprocess
import sys

from pydoctor_primer.model import Project

def update_projects(projects: list[Project], check: bool = False) -> None:
# modifies `get_projects` in place.
result = []
with open(__file__) as f:
keep = True
for line in f:
if line.endswith("\n"):
line = line[:-1]
if line == " projects = [":
result.append(f" projects = {projects!r}")
keep = False
if keep:
result.append(line)
if line == " ]":
keep = True

if check:
code_proc = subprocess.run(
["black", "-"], input="\n".join(result), capture_output=True, text=True
)
code_proc.check_returncode()
code = code_proc.stdout

with open(__file__) as f:
in_file = f.read()
if in_file != code:
diff = difflib.context_diff(
in_file.splitlines(keepends=True),
code.splitlines(keepends=True),
fromfile=__file__,
tofile=__file__,
)
print("".join(diff))
sys.exit(1)
else:
with open(__file__, "w") as f:
f.write("\n".join(result))


def get_projects() -> list[Project]:
projects = [
# PROJECTS USING PYDOCTOR
Project(
location="https://github.com/twisted/pydoctor",
pydoctor_cmd="{pydoctor} ./pydoctor --privacy='HIDDEN:pydoctor.test'",
expected_success=True
),
Project(
location="https://github.com/twisted/twisted",
pydoctor_cmd="{pydoctor} ./src/twisted --docformat=plaintext",
pydoctor_cmd="{pydoctor} ./src/twisted",
),
Project(
location="https://github.com/twisted/tubes",
pydoctor_cmd=("{pydoctor} ./tubes --privacy='HIDDEN:tubes.test' "
"--intersphinx=https://docs.python.org/3/objects.inv "
"--intersphinx=https://docs.twisted.org/en/stable/api/objects.inv "
"--intersphinx=https://zopeinterface.readthedocs.io/en/latest/objects.inv "),
revision='v0.2.1',
expected_success=True
),
Project(
location="https://github.com/temporalio/sdk-python",
pydoctor_cmd=("{pydoctor} --project-base-dir=. temporalio"),
),
Project(
location="https://github.com/agx/git-buildpackage",
pydoctor_cmd="{pydoctor} gbp",
revision='debian/0.9.32',
),
Project(
location="https://github.com/CMA-ES/pycma",
pydoctor_cmd="{pydoctor} cma --docformat=restructuredtext",
),
Project(
location="https://github.com/bw2/ConfigArgParse",
pydoctor_cmd=("{pydoctor} ./configargparse.py "
"--docformat=google "
"--intersphinx=https://docs.python.org/3/objects.inv")
),
Project(
location="https://github.com/numbbo/coco",
pydoctor_cmd=("{pydoctor} ./code-postprocessing/cocopp "
"--docformat=restructuredtext ")
),

# PROJECTS NOT USING PYDOCTOR
Project(
location="https://github.com/google/pytype",
pydoctor_cmd="{pydoctor} ./pytype/pytype --docformat=plaintext",
),
Project(
location="https://github.com/docutils/docutils",
pydoctor_cmd="{pydoctor} ./docutils/docutils --docformat=restructuredtext"
),
Project(
location="https://github.com/numpy/numpy",
pydoctor_cmd="{pydoctor} ./numpy --docformat=numpy"
),
Project(
location="https://github.com/scrapy/scrapy",
pydoctor_cmd="{pydoctor} ./scrapy --docformat=restructuredtext"
),
Project(
location="https://github.com/lxml/lxml",
pydoctor_cmd="{pydoctor} ./src/lxml --docformat=restructuredtext"
),
Project(
location="https://github.com/bottlepy/bottle",
pydoctor_cmd="{pydoctor} ./bottle.py --docformat=restructuredtext"
),
Project(
location="https://github.com/sphinx-doc/sphinx",
pydoctor_cmd="{pydoctor} ./sphinx --docformat=restructuredtext"
),
Project(
location="https://github.com/pylint-dev/pylint",
pydoctor_cmd="{pydoctor} ./pylint --docformat=restructuredtext"
),
Project(
location="https://github.com/pylint-dev/astroid",
pydoctor_cmd="{pydoctor} ./astroid --docformat=restructuredtext"
),
Project(
location="https://github.com/python-attrs/attrs",
pydoctor_cmd="{pydoctor} ./src/attr --docformat=restructuredtext"
),
Project(
location="https://github.com/pypa/twine",
pydoctor_cmd="{pydoctor} ./twine --docformat=restructuredtext",
),
Project(
location="https://github.com/urllib3/urllib3",
pydoctor_cmd="{pydoctor} ./src/urllib3 --docformat=restructuredtext",
),

]
assert len(projects) == len({p.name for p in projects})
return projects

0 comments on commit 5c75a3e

Please sign in to comment.