Skip to content

Commit 2ccb42d

Browse files
committed
Probably final report version
1 parent dd47f51 commit 2ccb42d

File tree

2 files changed

+54
-29
lines changed

2 files changed

+54
-29
lines changed

tastydoc/report/report.pdf

15 KB
Binary file not shown.

tastydoc/report/report.tex

Lines changed: 54 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,31 @@
11
\documentclass{report}
22
\usepackage{listings}
3+
\usepackage[dvipsnames]{xcolor}
4+
5+
\lstset{
6+
backgroundcolor=\color{white}, % choose the background color; you must add \usepackage{color} or \usepackage{xcolor}; should come as last argument
7+
basicstyle=\footnotesize, % the size of the fonts that are used for the code
8+
breakatwhitespace=false, % sets if automatic breaks should only happen at whitespace
9+
breaklines=true, % sets automatic line breaking
10+
captionpos=b, % sets the caption-position to bottom
11+
commentstyle=\color{green}, % comment style
12+
escapeinside={\%*}{*)}, % if you want to add LaTeX within your code
13+
extendedchars=true, % lets you use non-ASCII characters; for 8-bits encodings only, does not work with UTF-8
14+
frame=single, % adds a frame around the code
15+
keepspaces=true, % keeps spaces in text, useful for keeping indentation of code (possibly needs columns=flexible)
16+
keywordstyle=\color{blue}, % keyword style
17+
language=Scala, % the language of the code
18+
numbers=none, % where to put the line-numbers; possible values are (none, left, right)
19+
rulecolor=\color{black}, % if not set, the frame-color may be changed on line-breaks within not-black text (e.g. comments (green here))
20+
showspaces=false, % show spaces everywhere adding particular underscores; it overrides 'showstringspaces'
21+
showstringspaces=false, % underline spaces within strings only
22+
showtabs=false, % show tabs within strings adding particular underscores
23+
stepnumber=2, % the step between two line-numbers. If it's 1, each line will be numbered
24+
stringstyle=\color{mymauve}, % string literal style
25+
tabsize=2, % sets default tabsize to 2 spaces
26+
title=\lstname % show the filename of files included with \lstinputlisting; also try caption instead of title
27+
}
28+
329
\usepackage{hyperref}
430
\usepackage{tikz}
531
\usetikzlibrary{shapes.geometric, arrows, positioning}
@@ -26,8 +52,10 @@
2652

2753
\chapter{Introduction}
2854

55+
The repository for this project can be found here: \url{https://github.com/BryanAbate/dotty/tree/tastydoc/tastydoc}
56+
2957
A documentation tool is a program generating information (often in the form of HTML files) about projects. Usually, that tool includes method signatures, user-written documentation, links to other pages of the documentation, etc.
30-
In Dotty, the current tool for generating Scala project documentation is called Dottydoc. The tool introduced here, Tastydoc, aims to improve on Dottydoc and replace it.
58+
In Dotty, the current tool for generating Scala projects documentation is called Dottydoc. The tool introduced here, Tastydoc, aims to improve on Dottydoc and replace it.
3159

3260
Tastydoc uses TASTy files. These files contain information about the source code of a program. They become output when a program is compiled. Tastydoc consumes such files to extract information about the code, making its use completely independent of the compiler.
3361
The tool tries to be as close as possible to the structure proposed in Dottydoc so that it can reuse some portions of its code with minor modifications.
@@ -36,7 +64,7 @@ \chapter{Introduction}
3664

3765
The tool was developed with a few goals in mind. First, it should be independent of the compiler, hence the use of TASTy files. It should also produce humanly consumable files, hence the choice of Markdown as an output. Finally, it should have as many features as Dottydoc and be as easily maintainable.
3866

39-
The report is organized in the following structure: First, we will talk about the features of the tool. Then, we will give a high-level and a low-level architectural descriptions. Dottydoc and Tastydoc will then be compared. We will finally talk about the problems encountered during the development and the further work needed.
67+
The report is organized in the following structure: First, we will talk about the features of the tool. Then, we will give a high-level and a low-level architectural description. Dottydoc and Tastydoc will then be compared. We will finally talk about the problems encountered during the development and the further work needed.
4068

4169
\chapter{Features}
4270
We will list here the most important features of Tastydoc. For a comparison with Dottydoc features see \autoref{sec:comparison}.
@@ -47,30 +75,15 @@ \chapter{Features}
4775
For classes, traits, and objects the following are also available (when applicable): members, parents, constructors, known subclasses and companion.
4876
Packages know all their members as long as all corresponding TASTy files are passed as arguments to the tool.
4977

50-
User-written documentation, including individual access to defined @ such as \texttt{@param} (except \texttt{@usecase}). Two syntaxes are supported, which are the old Scaladoc Wiki-style syntax as well as Dottydoc Markdown syntax. Linking to entities (classes, methods, etc.) is possible inside the user documentation in the Wiki-style syntax using the notation like \texttt{[[scala.foo.bar]]}.
78+
User-written documentation, including individual access to defined @ such as \texttt{@param} (except \texttt{@usecase}) is available. Two syntaxes are supported, which are the old Scaladoc Wiki-style syntax as well as Dottydoc Markdown syntax. Linking to entities (classes, methods, etc.) is possible inside the user documentation in the Wiki-style syntax using the notation like \texttt{[[scala.foo.bar]]}.
5179

5280
\paragraph{TASTy}
5381
The tool relies on consuming TASTy files and is hence independent from the compiler.
5482

5583
\paragraph{Linking}
56-
Tastydoc is able to produce links to types defined outside of the current TASTy files (as well as the one inside the file). This is particularly useful for linking to the types of the parameters and return types, companions, scope modifiers, and parents.
57-
58-
\paragraph{Output}
59-
The tool produces Markdown documentation files that are easy to modify and read.
60-
61-
\chapter{Architecture}
62-
\section{High-level architectural descriptions}
63-
\subsection{TASTy}
64-
TASTy is a data format aimed at serializing compiler information about code. Dotty produces these files for each class, object without companion class or trait, trait and package if it contains something else than classes, traits or objects. Given its nature, TASTy is perfect to extract information.
65-
This is done through the use of the reflect API and the making of a class extending \texttt{TastyConsumer}\footnote{\texttt{scala/tasty/file/TastyConsumer.scala}}.
66-
67-
\subsection{High-level API}
68-
The tool offers an interface that is easy to use (called Representation, see \autoref{sec:representation}) to access all the information about an entity in a comprehensible format for anyone willing to write their own documentation tool without worrying to consume TASTy files.
69-
70-
\subsection{Reuse of Dottydoc intermediate representation}
71-
The intermediate structure (Representation) is similar to Dottydoc \texttt{Entity}\footnote{\texttt{dotty/tools/dottydoc/Entity.scala}} allowing to easily reuse parts of Dottydoc code with only minor modifications. Right now, the tool uses parts of Dottydoc code for parsing user documentation. However, it could produce the same HTML files as Dottydoc without relying on compiler internals. Especially since Dottydoc already has a complex templating mechanism that allows to attach blog posts to documentation and a search engine.
84+
Tastydoc is able to produce links to types defined outside of the current TASTy files (as well as the one inside the file). This is particularly useful for linking to the types of the parameters and the return types, companions, scope modifiers, and parents.
7285

73-
\subsection{Markdown}
86+
\paragraph{Markdown}
7487
Outputting Markdown instead of HTML has several advantages. It is easy to edit by hand, easily previewed, and users can easily add their own texts or files to it. A user could, for example, write a Markdown file and link it in the documentation of a class or do the opposite and link a documentation page in a Markdown file.
7588

7689
Markdown files can easily be uploaded for preview to GitHub or GitLab. In that way, it is very easy to upload documentation files along with the code of a project.
@@ -79,8 +92,8 @@ \subsection{Markdown}
7992
\begin{center}
8093
\begin{tikzpicture}[node distance=2cm]
8194
\node (write) [process] {User writes code and documentation};
82-
\node (compile) [process, below of=write] {Compiler produces Tasty files};
83-
\node (tool) [process, below of=compile] {Tastydoc consumes Tasty files and produces Markdown};
95+
\node (compile) [process, below of=write] {Compiler produces TASTy files};
96+
\node (tool) [process, below of=compile] {Tastydoc consumes TASTy files and produces Markdown};
8497
\node (user) [process, below of=tool] {User edits Markdown files or add files as he wishes};
8598
\node (HTML) [process, below of=user, right of=user, xshift=1.2cm] {Markdown files are consumed and transformed to another format(HTML, PDF, etc.)};
8699
\node (upload) [process, below of=user, left of=user, xshift=-1.2cm] {Markdown files are uploaded to a git hosting service or a website};
@@ -93,6 +106,18 @@ \subsection{Markdown}
93106
\end{tikzpicture}
94107
\end{center}
95108

109+
\chapter{Architecture}
110+
\section{High-level architectural descriptions}
111+
\subsection{TASTy}
112+
TASTy is a data format aimed at serializing compiler information about code. Dotty produces these files for each class, object without companion class or trait, trait and package if it contains something else than classes, traits or objects. Given its nature, TASTy is perfect to extract information.
113+
This is done through the use of the reflect API and the making of a class extending \texttt{TastyConsumer}\footnote{\texttt{scala/tasty/file/TastyConsumer.scala}}.
114+
115+
\subsection{High-level API}
116+
The tool offers an interface that is easy to use (called Representation, see \autoref{sec:representation}) to access all the information about an entity in a comprehensible format for anyone willing to write their own documentation tool without worrying to consume TASTy files.
117+
118+
\subsection{Reuse of Dottydoc intermediate representation}
119+
The intermediate structure (Representation) is similar to Dottydoc \texttt{Entity}\footnote{\texttt{dotty/tools/dottydoc/Entity.scala}} allowing to easily reuse parts of Dottydoc code with only minor modifications. Right now, the tool uses parts of Dottydoc code for parsing user documentation. However, it could produce the same HTML files as Dottydoc without relying on compiler internals. Especially since Dottydoc already has a complex templating mechanism that allows to attach blog posts to documentation and a search engine.
120+
96121
\section{Low-level architecture}
97122
\subsection{TastyExtractor}
98123
File: \texttt{dotty/tastydoc/TastyExtractor.scala}
@@ -159,18 +184,18 @@ \subsection{Representation}
159184
extends Representation with Modifiers
160185
with TypeParams
161186
\end{lstlisting}
162-
\item \texttt{EmulatedPackageRepresentation} This Representation allow to regroup every PackageRepresentation of the same package under the same Representation. In fact, Tasty will output a Tasty file for each entity in a package and the top of the \texttt{reflect.Tree} is a \texttt{reflect.PackageClause}. Thus, there will be multiple \texttt{PackageRepresentation} of the same package when converting multiple classes of the same package. That latter point can be problematic in regard to usability. This Representation counters that issue. When using an \texttt{EmulatedPackageRepresentation}, it looks to the user as if he were using a \texttt{PackageRepresentation} containing all the members of the package.
187+
\item \texttt{EmulatedPackageRepresentation} This Representation allows to regroup every PackageRepresentation of the same package under the same Representation. In fact, Tasty will output a Tasty file for each entity in a package and the top of the \texttt{reflect.Tree} is a \texttt{reflect.PackageClause}. Thus, there will be multiple \texttt{PackageRepresentation} of the same package when converting multiple classes of the same package. That latter point can be problematic in regard to usability. This Representation counters that issue. When using an \texttt{EmulatedPackageRepresentation}, it looks to the user as if he were using a \texttt{PackageRepresentation} containing all the members of the package.
163188
\end{itemize}
164189

165190
\subsection{DocPrinter}
166191
File: \texttt{dotty/tastydoc/DocPrinter.scala}
167192

168-
Object with methods that formats Representations and References to Markdown and writes them to files. Basically, it handles all the formatting and printing logic of the tool.
193+
Object with methods that formats Representations and References to Markdown and writes them to files. Basically, it handles all the formatting and writting logic of the tool.
169194

170195
\subsection{mdscala}
171196
File: \texttt{dotty/tastydoc/mdscala.scala}
172197

173-
Object that has helper methods for outputting markdown. Unfortunately, it does not handle escaping as it is a non-trivial task and would require a significant amount of time (see \autoref{sec:problems}).
198+
Object that has helper methods for outputting Markdown. Unfortunately, it does not handle escaping as it is a non-trivial task and would require a significant amount of time (see \autoref{sec:problems}).
174199

175200
\subsection{TastyDocConsumer}
176201
File: \texttt{dotty/tastydoc/TastyDocConsumer.scala}
@@ -184,7 +209,7 @@ \subsection{Main}
184209
Command line parameters are:
185210
\begin{itemize}
186211
\item \textbf{--syntax} \{\textit{wiki} or \textit{markdown}\} Syntax to use for user documentation parsing
187-
\item \textbf{--packagestolink} \{\textit{regex1 regex2 ...}\} Regexes to specify which packages should be linked when formatting References
212+
\item \textbf{--packagestolink} \{\textit{regex1 regex2 ...}\} Regexes of packages or entities (example: \texttt{scala.collection.*}). Only the types with a path matching these regexes will produce links in the documentation files
188213
\item \textbf{--classpath} \{\textit{URI}\} Extra classpath for input files
189214
\item \textbf{-i} \{\textit{file1 file2 ...}\} TASTy files
190215
\item \textbf{-d} \{\textit{dir1 dir2 ...}\} Directories to recursively find TASTy files
@@ -212,7 +237,7 @@ \section{Workflow}
212237
\end{tikzpicture}
213238
\end{center}
214239

215-
As we can see, parsing user documentation is only done after converting to Representation. Indeed, in order to link methods, classes, etc. from user documentation we need to have first converted everything to Representation. Otherwise, there is no way to know what is linked (a method? a class? an object?).
240+
As we can see, parsing user documentation is only done after converting to Representation. Indeed, in order to link methods, classes, etc. from user documentation we need to have first converted everything to Representation because the Wiki-style syntax does not tell us what is linked (a method? a class? an object?).
216241

217242

218243
\chapter{Comparison between Dottydoc and Tastydoc}
@@ -284,7 +309,7 @@ \chapter{Problems}
284309

285310
To mitigate this problem, we first output types and then values so that when linking it links to the first one appearing in the page which would be a type and it is what we want in most cases. However, this does not solve the problem of linking to type parameters and of linking to overloaded methods.
286311

287-
\chapter{Remaining work}
312+
\chapter{Further work}
288313
Although the project is nearly complete, some work needs to be done to perfect the tool.
289314

290315
\paragraph{Markdown escaping}
@@ -294,7 +319,7 @@ \chapter{Remaining work}
294319
Type Lambdas are complex types to handle and convert to References, right now they are converted to constant References. This is not the expected behaviour: the output is not the one we expect and no linking can be done this way. It is, however, acceptable for a first version as type lambdas do not appear that often.
295320

296321
\paragraph{Complex types}
297-
Assume the following type:
322+
Assume the following code:
298323
\begin{lstlisting}[language=scala]
299324
class Graph {
300325
type Node = Int

0 commit comments

Comments
 (0)