Skip to content

Commit 84958f8

Browse files
committed
TOFIX Bug in Dotty when calling owner
1 parent 4de61f2 commit 84958f8

21 files changed

+962
-16
lines changed

tastydoc/report/report.pdf

489 Bytes
Binary file not shown.

tastydoc/report/report.tex

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
commentstyle=\color{green}, % comment style
1212
escapeinside={\%*}{*)}, % if you want to add LaTeX within your code
1313
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
14+
frame=single, % adds a frame around the code
1515
keepspaces=true, % keeps spaces in text, useful for keeping indentation of code (possibly needs columns=flexible)
1616
keywordstyle=\color{blue}, % keyword style
1717
language=Scala, % the language of the code
@@ -22,7 +22,7 @@
2222
showtabs=false, % show tabs within strings adding particular underscores
2323
stepnumber=2, % the step between two line-numbers. If it's 1, each line will be numbered
2424
stringstyle=\color{purple}, % string literal style
25-
tabsize=2, % sets default tabsize to 2 spaces
25+
tabsize=2, % sets default tabsize to 2 spaces
2626
title=\lstname % show the filename of files included with \lstinputlisting; also try caption instead of title
2727
}
2828

@@ -43,7 +43,7 @@
4343
\begin{abstract}
4444
The current documentation tool (Dottydoc) relies on compiler internals and low-level code. The tool introduced in this work aims to build a program that does not depend on compiler internals but instead uses TASTy files. The latter become output when a Scala program is compiled.
4545

46-
This work also aims at providing a better maintained tool with fewer bugs and more features.
46+
This work also aims at providing a better-maintained tool with fewer bugs and more features.
4747

4848
The documentation files are in Markdown instead of the commonly used HTML.
4949
\end{abstract}
@@ -64,7 +64,7 @@ \chapter{Introduction}
6464

6565
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.
6666

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.
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 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.
6868

6969
\chapter{Features}
7070
We will list here the most important features of Tastydoc. For a comparison with Dottydoc features see \autoref{sec:comparison}.
@@ -116,7 +116,7 @@ \subsection{High-level API}
116116
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.
117117

118118
\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.
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 attaching blog posts to documentation and a search engine.
120120

121121
\section{Low-level architecture}
122122
\subsection{TastyExtractor}
@@ -190,7 +190,7 @@ \subsection{Representation}
190190
\subsection{DocPrinter}
191191
File: \texttt{dotty/tastydoc/DocPrinter.scala}
192192

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.
193+
Object with methods that formats Representations and References to Markdown and writes them to files. Basically, it handles all the formatting and writing logic of the tool.
194194

195195
\subsection{mdscala}
196196
File: \texttt{dotty/tastydoc/mdscala.scala}
@@ -260,7 +260,7 @@ \section{Extra features from Tastydoc}
260260
Tastydoc keeps track of all seen subclasses of a class and links to their documentation files.
261261

262262
\paragraph{Refined types}
263-
Tastydoc handles refined types where Dottydoc only remember the parent of the type.
263+
Tastydoc handles refined types where Dottydoc only remembers the parent of the type.
264264

265265
\section{Bugs in Dottydoc that Tastydoc fixes}
266266
Dottydoc is not really maintained and hence does not follow the evolution in Master. Some bugs are present in Dottydoc. Tastydoc fixes them all.
@@ -299,7 +299,7 @@ \chapter{Problems}
299299
A few problems were encountered during the tools' development, some could not be fixed for reasons detailed below.
300300

301301
\paragraph{Markdown escaping}
302-
We need a library to create a Markdown AST and render it to text, because the output is written in Markdown. The library also needs to escape the input. For instance, a method named "\#", will be interpreted as a header of level 1 if it is not escaped which is not the expected behaviour. This creates a problem because no such library exists in Java or Scala and taking care of Markdown escaping would be time-consuming and was not the main topic of this project.
302+
We need a library to create a Markdown AST and render it to text because the output is written in Markdown. The library also needs to escape the input. For instance, a method named "\#", will be interpreted as a header of level 1 if it is not escaped which is not the expected behaviour. This creates a problem because no such library exists in Java or Scala and taking care of Markdown escaping would be time-consuming and was not the main topic of this project.
303303

304304
\paragraph{Linking inside code blocks}
305305
We use code blocks indicating we have a piece of code so that a signature is formatted and syntax highlighted. In these code blocks, we also want to be able to make links pointing to the documentation page of a type. Unfortunately, Markdown fenced code blocks do not allow to have links in them. To counter this problem, we use HTML pre and code tag which are also understood by Markdown viewer. However, that causes two problems. First, it is not pure Markdown. Second, we lose the language syntax highlight from Markdown fenced code blocks.
@@ -312,6 +312,9 @@ \chapter{Problems}
312312

313313
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.
314314

315+
\paragraph{Bug when calling owner}
316+
At the time of writing the documentation tool display methods inherited from Object and Any and not overridden (which is not the desired behaviour) because a bug in Dotty makes the program crash when calling \texttt{owner} of a symbol.
317+
315318
\chapter{Further work}
316319
Although the project is nearly complete, some work needs to be done to perfect the tool.
317320

@@ -340,8 +343,4 @@ \chapter{Further work}
340343
\paragraph{HTML/CSS}
341344
Markdown files for documentation are good for all the reasons mentioned in this report. However, some people still want a good HTML/CSS documentation. The aim would be to either take back what Dottydoc has and use it with our code or build something new. The first case would be pretty straightforward as our intermediate representation looks very similar to Dottydoc. The biggest modification would be made to the References as links are handled a bit differently in this tool.
342345

343-
\end{document}
344-
345-
%Say that dottydoc does not have these features in problems?
346-
% Dottydoc no companion, not true?
347-
% Move Md to features from arch?
346+
\end{document}

tastydoc/src/dotty/tastydoc/TastyExtractor.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,10 @@ trait TastyExtractor extends TastyTypeConverter with CommentParser with CommentC
7070
!symbol.flags.is(Flags.Synthetic) &&
7171
!symbol.flags.is(Flags.Artifact) &&
7272
!symbol.flags.is(Flags.StableRealizable) && //Remove val generated for object definitions inside classes
73-
!symbol.name.contains("$default$") && //Remove artifact methods generated for methods with default parameters
74-
!(symbol.owner.name == "Object" && ownerPath == List("java", "lang")) &&//TOASK ERROR When calling owner
75-
!(symbol.owner.name == "Any" && ownerPath == List("scala")) //TOASK ERROR When calling owner
73+
!symbol.name.contains("$default$") &&//Remove artifact methods generated for methods with default parameters
74+
true //TOFIX Remove true and uncomment these lines when the bug in Dotty when calling owner is fixed
75+
//!(symbol.owner.name == "Object" && ownerPath == List("java", "lang")) &&
76+
//!(symbol.owner.name == "Any" && ownerPath == List("scala"))
7677
}
7778

7879
(body.flatMap{

tastydoc/zzz/example/DocumentationInheritance.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ example
66
<pre><code class="language-scala" >DocumentationInheritance()</pre></code>
77

88
## Concrete Value Members:
9+
### !=
10+
<pre><code class="language-scala" >final def !=(x$0: Any): Boolean</pre></code>
11+
12+
### ##
13+
<pre><code class="language-scala" >final def ##: Int</pre></code>
14+
915
### ++
1016
<pre><code class="language-scala" >def ++[B, That](that: GenTraversableOnce[B])(bf: CanBuildFrom[Repr, B, That]): That</pre></code>
1117

@@ -27,6 +33,9 @@ example
2733
### :\
2834
<pre><code class="language-scala" >def :\[B](z: B)(op: (A, B) => B): B</pre></code>
2935

36+
### ==
37+
<pre><code class="language-scala" >final def ==(x$0: Any): Boolean</pre></code>
38+
3039
### abstractDefinition
3140
<pre><code class="language-scala" >def abstractDefinition: Int</pre></code>
3241

@@ -51,9 +60,15 @@ example
5160
### applyOrElse
5261
<pre><code class="language-scala" >def applyOrElse[A1, B1](x: A1, default: (A1) => B1): B1</pre></code>
5362

63+
### asInstanceOf
64+
<pre><code class="language-scala" >final def asInstanceOf[X0]: X0</pre></code>
65+
5466
### canEqual
5567
<pre><code class="language-scala" >override def canEqual(that: Any): Boolean</pre></code>
5668

69+
### clone
70+
<pre><code class="language-scala" >protected def clone(): Object</pre></code>
71+
5772
### collect
5873
<pre><code class="language-scala" >def collect[B, That](pf: PartialFunction[A, B])(bf: CanBuildFrom[Repr, B, That]): That</pre></code>
5974

@@ -135,6 +150,9 @@ def someScalaCode(x: String) = println("Hello " + x)
135150
### endsWith
136151
<pre><code class="language-scala" >def endsWith[B](that: GenSeq[B]): Boolean</pre></code>
137152

153+
### eq
154+
<pre><code class="language-scala" >final def eq(x$0: Object): Boolean</pre></code>
155+
138156
### equals
139157
<pre><code class="language-scala" >override def equals(that: Any): Boolean</pre></code>
140158

@@ -150,6 +168,9 @@ def someScalaCode(x: String) = println("Hello " + x)
150168
### filterNot
151169
<pre><code class="language-scala" >def filterNot(p: (A) => Boolean): Repr</pre></code>
152170

171+
### finalize
172+
<pre><code class="language-scala" >protected def finalize(): Unit</pre></code>
173+
153174
### find
154175
<pre><code class="language-scala" >override def find(p: (A) => Boolean): Option[A]</pre></code>
155176

@@ -180,6 +201,9 @@ def someScalaCode(x: String) = println("Hello " + x)
180201
### genericBuilder
181202
<pre><code class="language-scala" >def genericBuilder[B]: Builder[B, CC[B]]</pre></code>
182203

204+
### getClass
205+
<pre><code class="language-scala" >final def getClass(): Class[Nothing <: Any]</pre></code>
206+
183207
### groupBy
184208
<pre><code class="language-scala" >def groupBy[K](f: (A) => K): Map[K, Repr]</pre></code>
185209

@@ -237,6 +261,9 @@ def someScalaCode(x: String) = println("Hello " + x)
237261
### isEmpty
238262
<pre><code class="language-scala" >override def isEmpty: Boolean</pre></code>
239263

264+
### isInstanceOf
265+
<pre><code class="language-scala" >final def isInstanceOf[X0]: Boolean</pre></code>
266+
240267
### isTraversableAgain
241268
<pre><code class="language-scala" >final def isTraversableAgain: Boolean</pre></code>
242269

@@ -329,9 +356,18 @@ Test methods with params
329356
### mkString
330357
<pre><code class="language-scala" >def mkString(start: String, sep: String, end: String): String</pre></code>
331358

359+
### ne
360+
<pre><code class="language-scala" >final def ne(x$0: Object): Boolean</pre></code>
361+
332362
### nonEmpty
333363
<pre><code class="language-scala" >def nonEmpty: Boolean</pre></code>
334364

365+
### notify
366+
<pre><code class="language-scala" >final def notify(): Unit</pre></code>
367+
368+
### notifyAll
369+
<pre><code class="language-scala" >final def notifyAll(): Unit</pre></code>
370+
335371
### orElse
336372
<pre><code class="language-scala" >def orElse[A1, B1](that: PartialFunction[A1, B1]): PartialFunction[A1, B1]</pre></code>
337373

@@ -470,6 +506,9 @@ Test methods with params
470506
### sum
471507
<pre><code class="language-scala" >def sum[B](num: Numeric[B]): B</pre></code>
472508

509+
### synchronized
510+
<pre><code class="language-scala" >final def synchronized[X0](x$0: X0): X0</pre></code>
511+
473512
### tail
474513
<pre><code class="language-scala" >override def tail: Repr</pre></code>
475514

@@ -557,6 +596,15 @@ Test methods with params
557596
### view
558597
<pre><code class="language-scala" >override def view: AnyRef & SeqView[A, Repr]</pre></code>
559598

599+
### wait
600+
<pre><code class="language-scala" >final def wait(x$0: Long, x$1: Int): Unit</pre></code>
601+
602+
### wait
603+
<pre><code class="language-scala" >final def wait(x$0: Long): Unit</pre></code>
604+
605+
### wait
606+
<pre><code class="language-scala" >final def wait(): Unit</pre></code>
607+
560608
### withFilter
561609
<pre><code class="language-scala" >def withFilter(p: (A) => Boolean): FilterMonadic[A, Repr]</pre></code>
562610

tastydoc/zzz/example/ReturnObjectWithType$.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,61 @@ example
66
### returnType
77
<pre><code class="language-scala" >type returnType: Int</pre></code>
88

9+
## Concrete Value Members:
10+
### !=
11+
<pre><code class="language-scala" >final def !=(x$0: Any): Boolean</pre></code>
12+
13+
### ##
14+
<pre><code class="language-scala" >final def ##: Int</pre></code>
15+
16+
### ==
17+
<pre><code class="language-scala" >final def ==(x$0: Any): Boolean</pre></code>
18+
19+
### asInstanceOf
20+
<pre><code class="language-scala" >final def asInstanceOf[X0]: X0</pre></code>
21+
22+
### clone
23+
<pre><code class="language-scala" >protected def clone(): Object</pre></code>
24+
25+
### eq
26+
<pre><code class="language-scala" >final def eq(x$0: Object): Boolean</pre></code>
27+
28+
### equals
29+
<pre><code class="language-scala" >def equals(x$0: Any): Boolean</pre></code>
30+
31+
### finalize
32+
<pre><code class="language-scala" >protected def finalize(): Unit</pre></code>
33+
34+
### getClass
35+
<pre><code class="language-scala" >final def getClass(): Class[Nothing <: Any]</pre></code>
36+
37+
### hashCode
38+
<pre><code class="language-scala" >def hashCode(): Int</pre></code>
39+
40+
### isInstanceOf
41+
<pre><code class="language-scala" >final def isInstanceOf[X0]: Boolean</pre></code>
42+
43+
### ne
44+
<pre><code class="language-scala" >final def ne(x$0: Object): Boolean</pre></code>
45+
46+
### notify
47+
<pre><code class="language-scala" >final def notify(): Unit</pre></code>
48+
49+
### notifyAll
50+
<pre><code class="language-scala" >final def notifyAll(): Unit</pre></code>
51+
52+
### synchronized
53+
<pre><code class="language-scala" >final def synchronized[X0](x$0: X0): X0</pre></code>
54+
55+
### toString
56+
<pre><code class="language-scala" >def toString(): String</pre></code>
57+
58+
### wait
59+
<pre><code class="language-scala" >final def wait(x$0: Long, x$1: Int): Unit</pre></code>
60+
61+
### wait
62+
<pre><code class="language-scala" >final def wait(x$0: Long): Unit</pre></code>
63+
64+
### wait
65+
<pre><code class="language-scala" >final def wait(): Unit</pre></code>
66+

tastydoc/zzz/example/ReturnTypeClass.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,61 @@ example
55
## Constructors:
66
<pre><code class="language-scala" >ReturnTypeClass()</pre></code>
77

8+
## Concrete Value Members:
9+
### !=
10+
<pre><code class="language-scala" >final def !=(x$0: Any): Boolean</pre></code>
11+
12+
### ##
13+
<pre><code class="language-scala" >final def ##: Int</pre></code>
14+
15+
### ==
16+
<pre><code class="language-scala" >final def ==(x$0: Any): Boolean</pre></code>
17+
18+
### asInstanceOf
19+
<pre><code class="language-scala" >final def asInstanceOf[X0]: X0</pre></code>
20+
21+
### clone
22+
<pre><code class="language-scala" >protected def clone(): Object</pre></code>
23+
24+
### eq
25+
<pre><code class="language-scala" >final def eq(x$0: Object): Boolean</pre></code>
26+
27+
### equals
28+
<pre><code class="language-scala" >def equals(x$0: Any): Boolean</pre></code>
29+
30+
### finalize
31+
<pre><code class="language-scala" >protected def finalize(): Unit</pre></code>
32+
33+
### getClass
34+
<pre><code class="language-scala" >final def getClass(): Class[Nothing <: Any]</pre></code>
35+
36+
### hashCode
37+
<pre><code class="language-scala" >def hashCode(): Int</pre></code>
38+
39+
### isInstanceOf
40+
<pre><code class="language-scala" >final def isInstanceOf[X0]: Boolean</pre></code>
41+
42+
### ne
43+
<pre><code class="language-scala" >final def ne(x$0: Object): Boolean</pre></code>
44+
45+
### notify
46+
<pre><code class="language-scala" >final def notify(): Unit</pre></code>
47+
48+
### notifyAll
49+
<pre><code class="language-scala" >final def notifyAll(): Unit</pre></code>
50+
51+
### synchronized
52+
<pre><code class="language-scala" >final def synchronized[X0](x$0: X0): X0</pre></code>
53+
54+
### toString
55+
<pre><code class="language-scala" >def toString(): String</pre></code>
56+
57+
### wait
58+
<pre><code class="language-scala" >final def wait(x$0: Long, x$1: Int): Unit</pre></code>
59+
60+
### wait
61+
<pre><code class="language-scala" >final def wait(x$0: Long): Unit</pre></code>
62+
63+
### wait
64+
<pre><code class="language-scala" >final def wait(): Unit</pre></code>
65+

0 commit comments

Comments
 (0)