commit acb8a9613a675c6db437831a2769fb56ee5555cc
Author: Dominik Poch <dpoch@email.cz>
Date:   Sat Apr 16 17:40:02 2022 +0200

    Added comments

diff --git a/webapp/components/annotation/AnnotationItem.tsx b/webapp/components/annotation/AnnotationItem.tsx
index c211590..439f25e 100644
--- a/webapp/components/annotation/AnnotationItem.tsx
+++ b/webapp/components/annotation/AnnotationItem.tsx
@@ -1,7 +1,6 @@
 import { Col, Container, Row, Stack } from 'react-bootstrap';
 import { Occurrence, Tag } from '../types/tag';
 import { ChangeEvent, useContext, useState } from 'react';
-
 import 'antd/dist/antd.css';
 import { Button, Input } from 'antd';
 import {
@@ -12,8 +11,20 @@ import {
 } from '@ant-design/icons';
 import { AnnotationContext } from '../../contexts/AnnotationContext';
 
+/**
+ * Creates a single item in an annotation panel.
+ * @param props Properties should contain a tag that will be shown in this annotation.
+ * @returns The item that represents an annotation.
+ */
 export function AnnotationItem(props: { tag: Tag }) {
+    /**
+     * Should properties of this annotation be visible?
+     */
     const [visibleProperties, setVisibleProperties] = useState(false);
+
+    /**
+     * Context that manages annotations.
+     */
     const {
         addOccurrence,
         deleteOccurrence,
@@ -22,28 +33,49 @@ export function AnnotationItem(props: { tag: Tag }) {
         changeLength,
     } = useContext(AnnotationContext);
 
+    /**
+     * Adds new occurrence of this annotation to the context.
+     */
     const onAddOccurrence = () => {
         addOccurrence(props.tag);
     };
 
+    /**
+     * Removes an occurrence of this annotation from the context.
+     * @param occurrence The occurrence that should be removed.
+     */
     const onDeleteOccurrence = (occurrence: Occurrence) => (e: any) => {
         deleteOccurrence(occurrence);
     };
 
+    /**
+     * Changes visibility of this annotation in the context.
+     */
     const onChangeVisibility = () => {
         changeVisibility(props.tag);
     };
 
+    /**
+     * Changes a position of an occurrence of this annotation in the context.
+     * @param occurrence The occurrence that should be changed.
+     */
     const onChangePosition =
         (occurrence: Occurrence) => (e: ChangeEvent<HTMLInputElement>) => {
             changePosition(occurrence, Number(e.currentTarget.value));
         };
 
+    /**
+     * Changes a length of an occurrence of this annotation in the context.
+     * @param occurrence The occurrence that should be changed.
+     */
     const onChangeLength =
         (occurrence: Occurrence) => (e: ChangeEvent<HTMLInputElement>) => {
             changeLength(occurrence, Number(e.currentTarget.value));
         };
 
+    /**
+     * Changes visibility of properties of this annotation.
+     */
     const changePropertiesVisibility = () => {
         setVisibleProperties(!visibleProperties);
     };
diff --git a/webapp/components/annotation/AnnotationPanel.tsx b/webapp/components/annotation/AnnotationPanel.tsx
index 7aa95df..346844e 100644
--- a/webapp/components/annotation/AnnotationPanel.tsx
+++ b/webapp/components/annotation/AnnotationPanel.tsx
@@ -11,6 +11,10 @@ import { Tag } from '../types/tag';
 export function AnnotationPanel() {
     //const { tags } = useContext(AnnotationContext);
 
+    /**
+     * Temporary values of tags.
+     * TODO: connect annotation panel to a context and use its tags.
+     */
     const tags: Tag[] = [
         {
             name: 'tag a',
diff --git a/webapp/components/modals/AddDocument.tsx b/webapp/components/modals/AddDocument.tsx
index eb7ab81..6386278 100644
--- a/webapp/components/modals/AddDocument.tsx
+++ b/webapp/components/modals/AddDocument.tsx
@@ -39,7 +39,7 @@ export function AddDocument(afterClose: () => {}) {
     };
 
     /**
-     * Handles successfull closing of the modal window.
+     * Handles successful closing of the modal window.
      */
     const handleOk = () => {
         /**
diff --git a/webapp/contexts/AnnotationContext.tsx b/webapp/contexts/AnnotationContext.tsx
index e7f49a6..7409aa1 100644
--- a/webapp/contexts/AnnotationContext.tsx
+++ b/webapp/contexts/AnnotationContext.tsx
@@ -1,49 +1,173 @@
-import React, { createContext, useContext, useEffect, useState } from 'react';
+import React, { createContext, useEffect, useState } from 'react';
 import { TagInstanceInfo } from '../api';
 import { Occurrence, Tag } from '../components/types/tag';
 
+/**
+ * Interface of an annotation context provider.
+ */
 interface IAnnotationContextProvider {
+    /**
+     * Tags managed by the context.
+     */
     tags: TagInstanceInfo[] | null;
+
+    /**
+     * Sets new tags.
+     * @param newTags An array of new tags.
+     */
     setTags: (newTags: TagInstanceInfo[] | null) => void;
+
+    /**
+     * Adds occurrence to an annotation.
+     * @param tag Tag whose occurrence should be added.
+     */
     addOccurrence: (tag: Tag) => void;
+
+    /**
+     * Changes visibility of an annotation.
+     * @param tag Tag whose visibility should be changed.
+     */
     changeVisibility: (tag: Tag) => void;
+
+    /**
+     * Deletes an occurrence of an annotation.
+     * @param occurrence Occurrence that should be deleted.
+     */
     deleteOccurrence: (occurrence: Occurrence) => void;
+
+    /**
+     * Changes a position of an occurrence of an annotation.
+     * @param occurrence Occurrence whose position should be changed.
+     * @param newValue New value of the position.
+     */
     changePosition: (occurrence: Occurrence, newValue: number) => void;
+
+    /**
+     * Changes a length of an occurrence of an annotation.
+     * @param occurrence Occurrence whose length should be changed.
+     * @param newValue New value of the length.
+     */
     changeLength: (occurrence: Occurrence, newValue: number) => void;
 }
 
+/**
+ * The annotation context that manages active annotations.
+ */
 export const AnnotationContext = createContext<IAnnotationContextProvider>({
+    /**
+     * Default tags.
+     */
     tags: null,
+
+    /**
+     * Default implementation of setTags method.
+     * @param v Array of new tags.
+     */
     setTags: (v) => {
         return;
     },
+
+    /**
+     * Default implementation of addOccurrence method.
+     * @param tag The tag with new occurrence.
+     */
     addOccurrence: (tag: Tag) => {
         return;
     },
+
+    /**
+     * Default implementation of changeVisibility method.
+     * @param tag The tag whose visibility should be changed.
+     */
     changeVisibility: (tag: Tag) => {
         return;
     },
+
+    /**
+     * Default implementation of deleteOccurrence method.
+     * @param occurrence Occurrence that should be deleted.
+     */
     deleteOccurrence: (occurrence: Occurrence) => {
         return;
     },
+
+    /**
+     * Default implementation of changePosition method.
+     * @param occurrence Occurrence whose position should be changed.
+     * @param newValue A new position.
+     */
     changePosition: (occurrence: Occurrence, newValue: number) => {
         return;
     },
+
+    /**
+     * Default implementation of changeLength method.
+     * @param occurrence Occurrence whose length should be changed.
+     * @param newValue A new length.
+     */
     changeLength: (occurrence: Occurrence, newValue: number) => {
         return;
     },
 });
 
+/**
+ * Provider of the annotation context.
+ * @param props Children that should have access to the annotation context.
+ * @returns Prepared html of the provider.
+ */
 const AnnotationProvider = (props: { children: React.ReactNode }) => {
+    /**
+     * Tags managed by the context.
+     */
     const [tags, setTags] = useState<TagInstanceInfo[] | null>(null);
-    const addOccurrence = (tag: Tag) => {};
-    const changeVisibility = (tag: Tag) => {};
-    const deleteOccurrence = (occurrence: Occurrence) => {};
-    const changePosition = (occurrence: Occurrence, newValue: number) => {};
-    const changeLength = (occurrence: Occurrence, newValue: number) => {};
 
+    /**
+     * Default implementation of addOccurrence method.
+     * @param tag The tag with new occurrence.
+     */
+    const addOccurrence = (tag: Tag) => {
+        //TODO: Implement method (should use objects from server API)
+    };
+
+    /**
+     * Changes visibility of an annotation.
+     * @param tag Tag whose visibility should be changed.
+     */
+    const changeVisibility = (tag: Tag) => {
+        //TODO: Implement method (should use objects from server API)
+    };
+
+    /**
+     * Deletes an occurrence of an annotation.
+     * @param occurrence Occurrence that should be deleted.
+     */
+    const deleteOccurrence = (occurrence: Occurrence) => {
+        //TODO: Implement method (should use objects from server API)
+    };
+
+    /**
+     * Changes a position of an occurrence of an annotation.
+     * @param occurrence Occurrence whose position should be changed.
+     * @param newValue New value of the position.
+     */
+    const changePosition = (occurrence: Occurrence, newValue: number) => {
+        //TODO: Implement method (should use objects from server API)
+    };
+
+    /**
+     * Changes a length of an occurrence of an annotation.
+     * @param occurrence Occurrence whose length should be changed.
+     * @param newValue New value of the length.
+     */
+    const changeLength = (occurrence: Occurrence, newValue: number) => {
+        //TODO: Implement method (should use objects from server API)
+    };
+
+    /**
+     * Initializes the context.
+     */
     useEffect(() => {
-        // on context init
+        //TODO: Implement initialization with values from the server
     }, []);
 
     return (
diff --git a/webapp/layouts/LoginLayout.tsx b/webapp/layouts/LoginLayout.tsx
index 05a1244..e087174 100644
--- a/webapp/layouts/LoginLayout.tsx
+++ b/webapp/layouts/LoginLayout.tsx
@@ -5,7 +5,7 @@ import { Col, Container, Row, Stack } from 'react-bootstrap';
 import React from 'react';
 
 /**
- * Creates layout of a login screen.
+ * Creates a layout of a login screen.
  * @param props Html structure of a login form.
  * @returns The login screen.
  */
diff --git a/webapp/pages/annotation/index.tsx b/webapp/pages/annotation/index.tsx
index ff51bb3..8afde00 100644
--- a/webapp/pages/annotation/index.tsx
+++ b/webapp/pages/annotation/index.tsx
@@ -4,7 +4,7 @@ import { TagPanel } from '../../components/annotation/TagPanel';
 import { MainLayout } from '../../layouts/MainLayout';
 import 'antd/dist/antd.css';
 import styles from '/styles/Annotation.module.scss';
-import AnnotationProvider, { AnnotationContext } from '../../contexts/AnnotationContext';
+import AnnotationProvider from '../../contexts/AnnotationContext';
 
 /**
  * Creates an annotation screen.
