/*

Copyright: All contributers to the Umple Project

This file is made available subject to the open source license found at:
https://umple.org/license

Model for generating documentation such as the Umple user manual
See Documenter_Code.ump for the methods injected into these classes
*/

namespace cruise.umple.compiler;

use Parser.ump;
use Parser_Code.ump;
use UmpleParser.ump;
external Position {}

namespace cruise.umple.docs;

/*
 * The tool to create the html text of the Umple user manual
 */
class Documenter
{
  depend java.io.*;
  depend java.net.*;
  depend cruise.umple.util.*;
  depend cruise.umple.compiler.*;
  
  inputPath;
  outputPath;
  String[] messages;
  Boolean seriousProblem = false;
  
  1 -> 0..1 ContentParser parser;
}

/* 
 * Data for the user manual taken from one of the files in 
 * build/reference
 */
class Content
{
  // Title of the user manual page
  title;

  // Legacy - to be deleted - used to represent whether cross-references should
  // Be created

  Boolean shouldIncludeReferences = true;

  // Html for the core of the manual page
  description;

  // Grammar rules associated with this user manual page
  syntax;
  
  // Original source filename
  filename;

  // Short samples of Umple code
  0..1 -> * ManualExample examples;
  
  // URL of Youtube Video (if any)
  videoURL = null;
  
  // URL of Markdown file to import (if any)
  markdownURL = null;
  
  // Tooltip to display when hovering (if any)
  tooltip = null;
}

class ManualExample {
  text;
  url = "";
  caption = ""; // If empty, then default caption will be used Example, Another Example
}

/*
 * A section of the Umple user manual
 * Defined in the build/references/order.group
 */
class Group
{
  name;
  lazy tooltip;
  1 -> * Content;
}

/* 
 * Specialist parser for the Umple user manual
 * Parses files in build/reference/*
 */
class ContentParser
{
  depend cruise.umple.compiler.Parser;
  depend cruise.umple.parser.Token;
  depend cruise.umple.parser.ParseResult;

  isA Parser;
  1 -> * Group;
}

/* 
 * Set of html templates used in the Umple User manual for certain
 * kinds of page elements
 */
class Template
{
  const HtmlHighlighterTemplate = htmlHighlighterTemplate();
  const HtmlCoreTemplate = htmlCoreTemplate();
  const HtmlTemplate = htmlTemplate();
  const ExampleTemplate = exampleTemplate();
  const SyntaxTemplate = syntaxTemplate();
  const VideoURLTemplate = videoURLTemplate();
  const MarkdownURLTemplate = markdownURLTemplate();
  const NavigationHeaderTemplate = navigationHeaderTemplate();
  const NavigationItemTemplate = navigationItemTemplate();
  const NavigationItemTemplateNoAnchor = navigationItemTemplateNoAnchor();
}

use Documenter_Code.ump;
