Skip to content

Commit

Permalink
Revert "Add numpydoc Renderer"
Browse files Browse the repository at this point in the history
This reverts commit 59ceb47.
  • Loading branch information
has2k1 committed Nov 2, 2023
1 parent dd2aa1f commit ac2a1bb
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 446 deletions.
1 change: 0 additions & 1 deletion quartodoc/renderers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@

from .base import Renderer
from .md_renderer import MdRenderer
from .numpydoc_renderer import NumpyDocRenderer
66 changes: 2 additions & 64 deletions quartodoc/renderers/base.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,7 @@
import re
from dataclasses import dataclass
from typing import Optional

from plum import dispatch

from quartodoc.pandoc.inlines import Link

@dataclass
class InterLink(Link):
"""
Link with target enclosed in colons
These targets of these links are interlink references
that are finally resolved by the interlinks filter.
"""
def __post_init__(self):
self.target = f":{self.target}:"

# utils -----------------------------------------------------------------------

Expand Down Expand Up @@ -44,52 +30,6 @@ def convert_rst_link_to_md(rst):
return re.sub(expr, r"[](\1)", rst, flags=re.MULTILINE)


def interlink_ref_to_link(interlink_ref: tuple[str|None, str]) -> InterLink:
"""
Convert an rst reference to a quoted link
The interlink has been parsed into a tuple form.
e.g.
1. Written as - ":meth:`class.some_method`:"
Parsed value - ("class.some_method", "meth")
Return value is a link with target - "`:meth:class.some_method`"
2. Written as - "class.some_method"
Parsed value - ("class.some_method", None)
Return value is a link with target - "`class.some_method`"
This method creates a link that can be represented in
markdown and that is later processed by the lua interlinks
filter into its final form.
"""
name, role = interlink_ref
target = f":{role}:{name}:" if role else f"{name}"
return InterLink(content=name, target=target)


def build_parameter(name: str, annotation: Optional[str], default: Optional[str]) -> str:
"""
Create code snippet that defines a parameter
"""
if not name and annotation:
# e.g. Return values may not have a name
return f"{annotation}"

if default is None:
if annotation:
param = f"{name}: {annotation}"
else:
param = f"{name}"
else:
if annotation:
param = f"{name}: {annotation} = {default}"
else:
param = f"{name}={default}"

return param

# render -----------------------------------------------------------------------


Expand All @@ -100,10 +40,8 @@ class Renderer:
def __init_subclass__(cls, **kwargs):
super().__init_subclass__(**kwargs)

# NOTE: Commented out temporarily to make it easit to reload
# modules during dev
# if cls.style in cls._registry:
# raise KeyError(f"A builder for style {cls.style} already exists")
if cls.style in cls._registry:
raise KeyError(f"A builder for style {cls.style} already exists")

cls._registry[cls.style] = cls

Expand Down
Loading

0 comments on commit ac2a1bb

Please sign in to comment.