Skip to content

Commit

Permalink
Fix nested comments, make links highlighted in the scaladoc, add @con…
Browse files Browse the repository at this point in the history
…structor keyword, remove dead code, add snap tests for comments.
  • Loading branch information
PanAeon committed Jun 24, 2019
1 parent 5211d13 commit 6fecc7d
Show file tree
Hide file tree
Showing 3 changed files with 675 additions and 15 deletions.
25 changes: 10 additions & 15 deletions src/typescript/Scala.tmLanguage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,19 +119,6 @@ export const scalaTmLanguage: TmLanguage = {
}
]
},
'block-comments': {
end: '\\*/',
begin: '/\\*',
patterns: [
{
include: '#block-comments'
},
{
match: '(?x)(?! /\\*)(?! \\*/)'
}
],
name: 'comment.block.scala'
},
'script-header': {
match: '^#!(.*)$',
captures: {
Expand Down Expand Up @@ -697,7 +684,7 @@ export const scalaTmLanguage: TmLanguage = {
}
},
{
match: '@(return|see|note|example|usecase|author|version|since|todo|deprecated|migration|define|inheritdoc)\\b',
match: '@(return|see|note|example|constructor|usecase|author|version|since|todo|deprecated|migration|define|inheritdoc)\\b',
name: 'keyword.other.documentation.scaladoc.scala'
},
{
Expand All @@ -707,12 +694,15 @@ export const scalaTmLanguage: TmLanguage = {
name: 'punctuation.definition.documentation.link.scala'
},
'2': {
name: 'entity.other.documentation.link.scala'
name: 'string.other.link.title.markdown'
},
'3': {
name: 'punctuation.definition.documentation.link.scala'
}
}
},
{
"include": "#comments"
}
],
endCaptures: {
Expand All @@ -730,6 +720,11 @@ export const scalaTmLanguage: TmLanguage = {
name: 'punctuation.definition.comment.scala'
}
},
patterns: [
{
"include": "#comments"
}
],
name: 'comment.block.scala'
},
{
Expand Down
141 changes: 141 additions & 0 deletions tests/snap/comments.test.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
/// SYNTAX TEST "source.scala"
#!/usr/bin/env scala

// single line comments

/* /**/ /** */ /* comments within comments */ */

/** /* */ /** **/ **/


/************************
*
* [[scala.Option]]
* @return smth
***********************/

case class C(val x: Int) {
def f(p:Double) : String = {

}
}

/** Provides classes for dealing with complex numbers. Also provides
* implicits for converting to and from `Int`.
*
* ==Overview==
* The main class to use is [[my.package.complex.Complex]], as so
* {{{
* scala> val complex = Complex(4,3)
* complex: my.package.complex.Complex = 4 + 3i
* }}}
*
* If you include [[my.package.complex.ComplexConversions]], you can
* convert numbers more directly
* {{{
* scala> import my.package.complex.ComplexConversions._
* scala> val complex = 4 + 3.i
* complex: my.package.complex.Complex = 4 + 3i
* }}}
*/
package complex {}

/** A person who uses our application.
*
* @constructor create a new person with a name and age.
* @tparam T useless param
* @param name the person's name
* @param age the person's age in years
* @throws java.lang.Exception
*
* @see reference other sources of information like external document links or related entities in the documentation.
* @note add a note for pre or post conditions, or any other notable restrictions or expectations.
* @example for providing example code or related example documentation.
* @usecase def apply(name: String, age: Int) : Unit
*
* @groupname group name
* @groupprio group 2
* @groupdesc group desc
* @group group
* @contentDiagram
*
*
* @author provide author information for the following entity
* @version the version of the system or API that this entity is a part of.
* @since like @version but defines the system or API that this entity was first defined in.
* @todo for documenting unimplemented features or unimplemented aspects of an entity.
* @deprecated marks the entity as deprecated, providing both the replacement implementation that should be used and the version/date at which this entity was deprecated.
* @migration like deprecated but provides advanced warning of planned changes ahead of deprecation. Same fields as @deprecated.
* @inheritdoc take comments from a superclass as defaults if comments are not provided locally.
* @documentable Expand a type alias and abstract type into a full template page. - TODO: Test the “abstract type” claim - no examples of this in the Scala code base
*
* @define <name> <definition>
*
* @shortDescription ???
* @hideImplicitConversion ???
*
*/
class Person[T](name: String, age: Int) {
}

/** Factory for [[mypackage.Person]] instances. */
object Person {
/** Creates a person with a given name and age.
*
* @param name their name
* @param age the age of the person to create
*/
def apply(name: String, age: Int) = {}

/** Creates a person with a given name and birthdate
*
* @param name their name
* @param birthDate the person's birthdate
* @return a new Person instance with the age determined by the
* birthdate and current date.
*/
def apply(name: String, birthDate: java.util.Date) = {}
}

/** Implicit conversions and helpers for [[mypackage.Complex]] instances.
*
* {{{
* import ComplexImplicits._
* val c: Complex = 4 + 3.i
* }}}
*/
object ComplexImplicits {}

/**
* =Heading=, ==Sub-Heading==
*
* `monospace`
* ''italic text''
* '''bold text'''
* __underline__
* ^superscript^
* ,,subscript,,
* [[entity link]], e.g. [[scala.collection.Seq]]
* [[http://external.link External Link]],
* e.g. [[http://scala-lang.org Scala Language Site]]
*
*/
object Markup {
/** Here is an unordered list:
*
* - First item
* - Second item
* - Sub-item to the second
* - Another sub-item
* - Third item
*
* Here is an ordered list:
*
* 1. First numbered item
* 1. Second numbered item
* i. Sub-item to the second
* i. Another sub-item
* 1. Third item
*/
def lists = ()
}
Loading

0 comments on commit 6fecc7d

Please sign in to comment.