You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The repository for this project can be found here: \url{https://github.com/BryanAbate/dotty/tree/tastydoc/tastydoc}
56
+
29
57
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.
31
59
32
60
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.
33
61
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}
36
64
37
65
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.
38
66
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.
40
68
41
69
\chapter{Features}
42
70
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}
47
75
For classes, traits, and objects the following are also available (when applicable): members, parents, constructors, known subclasses and companion.
48
76
Packages know all their members as long as all corresponding TASTy files are passed as arguments to the tool.
49
77
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]]}.
51
79
52
80
\paragraph{TASTy}
53
81
The tool relies on consuming TASTy files and is hence independent from the compiler.
54
82
55
83
\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.
72
85
73
-
\subsection{Markdown}
86
+
\paragraph{Markdown}
74
87
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.
75
88
76
89
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}
79
92
\begin{center}
80
93
\begin{tikzpicture}[node distance=2cm]
81
94
\node (write) [process] {User writes code and documentation};
\node (user) [process, below of=tool] {User edits Markdown files or add files as he wishes};
85
98
\node (HTML) [process, below of=user, right of=user, xshift=1.2cm] {Markdown files are consumed and transformed to another format(HTML, PDF, etc.)};
86
99
\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}
93
106
\end{tikzpicture}
94
107
\end{center}
95
108
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.
\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.
163
188
\end{itemize}
164
189
165
190
\subsection{DocPrinter}
166
191
File: \texttt{dotty/tastydoc/DocPrinter.scala}
167
192
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.
169
194
170
195
\subsection{mdscala}
171
196
File: \texttt{dotty/tastydoc/mdscala.scala}
172
197
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}).
\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
188
213
\item\textbf{--classpath} \{\textit{URI}\} Extra classpath for input files
\item\textbf{-d} \{\textit{dir1 dir2 ...}\} Directories to recursively find TASTy files
@@ -212,7 +237,7 @@ \section{Workflow}
212
237
\end{tikzpicture}
213
238
\end{center}
214
239
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?).
216
241
217
242
218
243
\chapter{Comparison between Dottydoc and Tastydoc}
@@ -284,7 +309,7 @@ \chapter{Problems}
284
309
285
310
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.
286
311
287
-
\chapter{Remaining work}
312
+
\chapter{Further work}
288
313
Although the project is nearly complete, some work needs to be done to perfect the tool.
289
314
290
315
\paragraph{Markdown escaping}
@@ -294,7 +319,7 @@ \chapter{Remaining work}
294
319
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.
0 commit comments