Skip to content

Commit

Permalink
Fix titles and build sphinx
Browse files Browse the repository at this point in the history
  • Loading branch information
Huowl committed Oct 17, 2023
1 parent 0140bbd commit f052bca
Show file tree
Hide file tree
Showing 11 changed files with 145 additions and 103 deletions.
13 changes: 12 additions & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,19 @@
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
import sys
import sys, mock
import os
from pathlib import Path

devdir=''
try:
if os.environ['DEVDIR']:
devdir = os.environ['DEVDIR']
except KeyError:
print 'Unable to obtain $DEVDIR from the environment.'
exit(-1)

sys.path.insert(0, os.path.abspath('.'))
sys.path.insert(0, str(Path(__file__).parent / '../../'))
sys.path.insert(0, str(Path(__file__).parent / '../../rostok'))

Expand All @@ -30,6 +40,7 @@

extensions = ['sphinx.ext.autodoc', 'sphinx.ext.napoleon','sphinx.ext.githubpages']

autodoc_member_order = 'groupwise'

napoleon_google_docstring = False
napoleon_use_param = False
Expand Down
4 changes: 2 additions & 2 deletions docs/source/modules/block_builder.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ Block builder
=============

Block blueprints
============
================

.. automodule:: rostok.block_builder_api.block_blueprints
:members:
:undoc-members:

Block parameters
=======
================

.. automodule:: rostok.block_builder_api.block_parameters
:members:
Expand Down
2 changes: 1 addition & 1 deletion docs/source/modules/criterion.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ Criterion calculation
Flag stop simulation
====================

.. automodule:: rostok.criterion.simulation_flag
.. automodule:: rostok.criterion.simulation_flags
:members:
2 changes: 1 addition & 1 deletion docs/source/modules/graph_generators.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ MCTS


MCTS Manager
==================
============

.. automodule:: rostok.graph_generators.mcts_manager
:members:
Expand Down
2 changes: 1 addition & 1 deletion docs/source/modules/graph_grammar.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Node
:members:

Graph-grammar explorer
==============
======================

.. automodule:: rostok.graph_grammar.graphgrammar_explorer
:members:
Expand Down
10 changes: 5 additions & 5 deletions docs/source/modules/simulation_chrono.rst
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
==================
===========================
Simulation in ProjectChrono
==================
===========================

Simulation scenario
===============
==================

.. automodule:: rostok.simulation_chrono.simulation_scenario
:members:

Simulation
==================
==========

.. automodule:: rostok.simulation_chrono.simulation
:members:

Simulation utils
==================
================

.. automodule:: rostok.simulation_chrono.simulation_utils
:members:
2 changes: 1 addition & 1 deletion docs/source/modules/utils.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Utils
=====

Pickle save
=================
===========

.. automodule:: rostok.utils.pickle_save
:members:
Expand Down
6 changes: 3 additions & 3 deletions docs/source/modules/virtual_experiment.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ Virtual experiment
==================

Robot
===============
=====

.. automodule:: rostok.virtual_experiment.robot_new
:members:

Auxilarity sensors
==================
Sensors
=======

.. automodule:: rostok.virtual_experiment.sensors
:members:
2 changes: 1 addition & 1 deletion rostok/block_builder_api/block_blueprints.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def __init__(self, *args: object) -> None:
super().__init__('Need implementation for method in child class')


class BlockCreatorInterface():
class BlockCreatorInterface:
""" To use it, you need to implement functions for creating from blueprints.
Raises:
Expand Down
64 changes: 34 additions & 30 deletions rostok/graph_grammar/node_vocabulary.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
""" Module contains NodeVocabulary class."""

from typing import Optional

from rostok.block_builder_api.block_blueprints import ALL_BLUEPRINT
from rostok.graph_grammar.node import ROOT, Node


class NodeVocabulary():
class NodeVocabulary:
"""The class contains dictionary of nodes and methods to manipulate with it.
This is a class to manage a dictionary of nodes. The keys are labels of the nodes and
the values are Node objects. User can create or add nodes to vocabulary, get individual
nodes or list of nodes.
Attributes:
node_dict (List[Node]): dictionary of all nodes.
terminal_node_dict (List[Node]): dictionary of only terminal nodes.
Expand All @@ -26,41 +24,47 @@ def __init__(self):

def add_node(self, node: Node):
"""Add an already created node to the vocabulary.
Args:
node (Node): node to be added to vocabulary.
Raises:
Exception: Attempt to add a Node with a label that is already in dictionary!
"""
if node.label in self.node_dict:
raise Exception('Attempt to add a Node with a label that is already in dictionary!')
raise Exception(
"Attempt to add a Node with a label that is already in dictionary!"
)

self.node_dict[node.label] = node
if node.is_terminal:
self.terminal_node_dict[node.label] = node
else:
self.nonterminal_node_dict[node.label] = node

def create_node(self,
label: str,
is_terminal: bool = False,
block_blueprint: Optional[ALL_BLUEPRINT] = None):
def create_node(
self,
label: str,
is_terminal: bool = False,
block_blueprint: Optional[ALL_BLUEPRINT] = None,
):
"""Create a node and add it to the vocabulary.
Args:
label (str): the label of the new node.
is_terminal (bool, optional): defines if the new node is a terminal node. Default
is False.
block_blueprint (BlockBlueprint, optional): the object that contains physical properties
of the node. Default is None.
Raises:
Exception: Attempt to add a Node with a label that is already in dictionary!
"""

if label in self.node_dict:
raise Exception('Attempt to create a Node with a label that is already in dictionary!')
raise Exception(
"Attempt to create a Node with a label that is already in dictionary!"
)

node = Node(label, is_terminal, block_blueprint)
self.node_dict[label] = node
Expand All @@ -71,13 +75,13 @@ def create_node(self,

def get_node(self, label: str) -> Node:
"""Return a node corresponding to the label.
Args:
label(str): the label of the node that should be returned.
Returns:
A requested node as a Node class object.
Raises
Exception: Node with given label not found!
"""
Expand All @@ -90,10 +94,10 @@ def get_node(self, label: str) -> Node:

def check_node(self, label: str) -> bool:
"""Check if the label is in the vocabulary.
Args:
label(str): the label of the node that should be checked.
Returns:
bool: True is the label is in dictionary, False otherwise.
"""
Expand All @@ -110,10 +114,10 @@ def __str__(self):

def get_list_of_nodes(self, nodes: list[str]) -> list[Node]:
"""Returns list of Node objects corresponding to list of labels.
Args:
nodes (list[str]): list of labels to construct a list of Node objects.
Returns:
list of Node objects corresponding to the list of passed labels.
"""
Expand All @@ -123,14 +127,14 @@ def get_list_of_nodes(self, nodes: list[str]) -> list[Node]:
return result


if __name__ == '__main__':
if __name__ == "__main__":
node_vocab = NodeVocabulary()
node_vocab.add_node(ROOT)
node_vocab.create_node('A')
node_vocab.create_node('B')
node_vocab.create_node('C')
node_vocab.create_node('D')
node_vocab.create_node('A1', is_terminal=True)
node_vocab.create_node('B1', is_terminal=True)
node_vocab.create_node('C1', is_terminal=True)
print(node_vocab)
node_vocab.create_node("A")
node_vocab.create_node("B")
node_vocab.create_node("C")
node_vocab.create_node("D")
node_vocab.create_node("A1", is_terminal=True)
node_vocab.create_node("B1", is_terminal=True)
node_vocab.create_node("C1", is_terminal=True)
print(node_vocab)
Loading

0 comments on commit f052bca

Please sign in to comment.