# Webpage Modules

## Classes Supporting Webpage Building

class environment_generation.website_util.Page(page_id)

  Bases: `object`

  Represents a collection of primitives within a website.

  Attributes:

    primitives (list): A list of primitive objects on the page. total_num_dom_elements (int): Total number of DOM elements associated with all primitives on the page. difficulty (float): Difficulty level of the page. page_id (str): Identifier for the page.

  Methods:

    __init__: Initializes a Page object with the given page ID. num_primitives: Returns the number of primitives on the page. active_primitives: Returns a list of active primitives on the page. passive_primitives: Returns a list of passive (non-active) primitives on the page. add_primitive: Adds a primitive to the page. calculate_difficulty: Computes and returns the difficulty of the page based on primitive interactions.

  Example:

        >>> page = Page('home')
        >>> print(page.num_primitives)
        0

  property active_primitives

    Returns a list of active primitives on the page.

    Returns:

      list: List of active primitives on the page.

  add_primitive(primitive)

    Adds a primitive to the page.

    Args:

      primitive (Primitive): The primitive to be added to the page.

  calculate_difficulty()

    Computes and returns the difficulty of the page based on the probability of a random agent interacting with the correct primitives.

    Returns:

      float: The calculated difficulty of the page.

  property num_primitives

    Returns the number of primitives on the page.

    Returns:

      int: Number of primitives on the page.

  property passive_primitives

    Returns a list of passive (non-active) primitives on the page.

    Returns:

      list: List of passive primitives on the page.

class environment_generation.website_util.Primitive(name, primitive_id=None)

  Bases: `object`

  Represents a primitive element on a web page.

  Attributes:

    name (str): Name of the primitive. primitive_id (int, optional): ID of the primitive, used to identify the primitive especially when multiple primitives of the same type exist on a page. num_dom_elements (int): Number of DOM elements associated with the primitive. is_active (bool): Indicates whether the primitive is active or not.

  Methods:

    __init__: Initializes a primitive with the given name and optional ID. __str__: Returns a string representation of the primitive. __repr__: Returns a string representation of the primitive suitable for debugging.

  Example:

        >>> primitive = Primitive('button', primitive_id=1)
        >>> print(primitive)
        button:1. Active: True

class environment_generation.website_util.Website(design=None, pages=None)

  Bases: `object`

  A Website is a sequence of pages, representing a complete website structure.

  Attributes:

    difficulty (float): The difficulty level of the entire website. _pages (list): A list of Page objects representing the pages of the website.

  Methods:

    __init__: Initializes a Website object with provided design or pages. _calculate_difficulty: Computes and updates the difficulty of the entire website. add_page: Adds a page to the website. remove_page: Removes a page from the website. convert_to_design: Converts the website structure into a design dictionary format.

  add_page(page)

    Adds a page to the website.

    Args: page (Page): The page to be added to the website.

  convert_to_design()

    Converts the website structure into a design dictionary format.

    Returns: dict: A dictionary representing the design of the website.

  remove_page(page)

    Removes a page from the website.

    Args: page (Page): The page to be removed from the website.

environment_generation.website_util.main(_)