# Generated by detroit
# See https://github.com/bourbonut/detroit/tree/main/api_maker

from functools import partial
from operator import is_not

class link:
    def __init__(self, content="link"):
        self.content = content

    def __repr__(self):
        return self.content

    def __str__(self):
        return self.content

    def __call__(self, *args):
        arguments = ", ".join(map(repr, args))
        return f"{self}({arguments})"

    def source(self, source=None):
        """
        Source · If source is specified, sets the source accessor to the specified function and
        returns this link generator.
        .. code:: javascript

            const link = d3.linkHorizontal().source((d) => d[0]);

        If source is not specified, returns the current source accessor.
        .. code:: javascript

            link.source() // (d) => d[0]

        The source accessor defaults to:
        .. code:: javascript

            function source(d) {
              return d.source;
            }


        See more informations `here <https://d3js.org/d3-shape/link#link_source>`_.
        """
        arguments = ", ".join(map(repr, filter(partial(is_not, None), (source,))))
        return link(content=f"{self.content}.source({arguments})")


    def target(self, target=None):
        """
        Source · If target is specified, sets the target accessor to the specified function and
        returns this link generator.
        .. code:: javascript

            const link = d3.linkHorizontal().target((d) => d[1]);

        If target is not specified, returns the current target accessor.
        .. code:: javascript

            link.target() // (d) => d[1]

        The target accessor defaults to:
        .. code:: javascript

            function target(d) {
              return d.target;
            }


        See more informations `here <https://d3js.org/d3-shape/link#link_target>`_.
        """
        arguments = ", ".join(map(repr, filter(partial(is_not, None), (target,))))
        return link(content=f"{self.content}.target({arguments})")


    def x(self, x=None):
        """
        Source · If x is specified, sets the x-accessor to the specified function or number and
        returns this link generator.
        .. code:: javascript

            const link = d3.linkHorizontal().x((d) => x(d.x));

        If x is not specified, returns the current x accessor.
        .. code:: javascript

            link.x() // (d) => x(d.x)

        The x accessor defaults to:
        .. code:: javascript

            function x(d) {
              return d[0];
            }


        See more informations `here <https://d3js.org/d3-shape/link#link_x>`_.
        """
        arguments = ", ".join(map(repr, filter(partial(is_not, None), (x,))))
        return link(content=f"{self.content}.x({arguments})")


    def y(self, y=None):
        """
        Source · If y is specified, sets the y-accessor to the specified function or number and
        returns this link generator.
        .. code:: javascript

            const link = d3.linkHorizontal().y((d) => y(d.y));

        If y is not specified, returns the current y accessor.
        .. code:: javascript

            link.y() // (d) => y(d.y)

        The y accessor defaults to:
        .. code:: javascript

            function y(d) {
              return d[1];
            }


        See more informations `here <https://d3js.org/d3-shape/link#link_y>`_.
        """
        arguments = ", ".join(map(repr, filter(partial(is_not, None), (y,))))
        return link(content=f"{self.content}.y({arguments})")


    def context(self, context=None):
        """
        Source · If context is specified, sets the context and returns this link generator.
        .. code:: javascript

            const context = canvas.getContext("2d");
            const link = d3.link().context(context);

        If context is not specified, returns the current context.
        .. code:: javascript

            link.context() // context

        The context defaults to null. If the context is not null, then the generated link is
        rendered to this context as a sequence of path method calls. Otherwise, a path data
        string representing the generated link is returned. See also d3-path.

        See more informations `here <https://d3js.org/d3-shape/link#link_context>`_.
        """
        arguments = ", ".join(map(repr, filter(partial(is_not, None), (context,))))
        return link(content=f"{self.content}.context({arguments})")


    def digits(self, digits=None):
        """
        Source · If digits is specified, sets the maximum number of digits after the decimal
        separator and returns this link generator.
        .. code:: javascript

            const link = d3.link().digits(3);

        If digits is not specified, returns the current maximum fraction digits, which defaults
        to 3.
        .. code:: javascript

            link.digits() // 3

        This option only applies when the associated context is null, as when this link
        generator is used to produce path data.

        See more informations `here <https://d3js.org/d3-shape/link#link_digits>`_.
        """
        arguments = ", ".join(map(repr, filter(partial(is_not, None), (digits,))))
        return link(content=f"{self.content}.digits({arguments})")

