SlideShare a Scribd company logo
1 of 22
Scaladoc for reflection
    (new features in 2.10)




                                  Vlad Ureche
                             19th of July 2012
Outline
●   2.10 scaladoc new features
    –   @inheritdoc
    –   Diagrams
    –   @template (or @documentable)
    –   Groups
    –   Skip packages
    –   Links
@inheritdoc
trait Base {
  /** Type represents a scala type. */
  type Type < : TypeBase
}
trait Api {
  /** @inheritdoc
   *
   * More details added later. */
  abstract class Type ...
}
@inheritdoc




              Comment inheritance
Diagrams
●   Two types
    –   inheritance diagrams
        ●   contain superclasses, subclasses and implicits
        ●   generated by default for classes and traits
    –   content diagrams
        ●   classes/traits/objects contained
        ●   generated by default for packages and objects
●   Oh noes
    –   trait Base will only get an inheritance diagram, no
        contents :((
Diagrams
●   You can override default behavior
    –   @inheritanceDiagram
    –   @contentDiagram
    –   add the annotation to get the diagram
    –   add hideDiagram to get rid of the diagram
    –   undesirable node? hideNodes "*internal*"
    –   undesirable edge? hideEdges("*A" -> "*B")
Diagrams

/** Description of the base trait
  * @contentDiagram
  * @inheritanceDiagram hideDiagram
  */
trait Base {
   /** Type represents a scala type. */
   type Type < : TypeBase
}
Diagrams




               Try clicking Type.
           Oh noes, it doesn't work!
            Type is an abstract type
@template / @documentable
●   Add this to your {abstract,alias} type
    –   to get a page for the type
    –   to get a clickable node in the template
@template / @documentable

trait Base {
  /** Type represents a scala type.
   * @template
   */
  type Type < : TypeBase
}
@template / @documentable

trait Base {
  /** Type represents a scala type.
   * @template
   */
  type Type < : TypeBase
}
@template
              Also finds values and treats
              them as companion objects




CLICK
Groups
●   scala.reflect.api.Types defines 46 types
    –   useful types (Type, TypeRef, …)
    –   classes that give the methods (TypeRefApi, ...)
    –   extractors (TypeRefExtractor, …)
●   wouldn't it be nice to group them?
Groups
package scala.reflect
package api

/**
 * @groupdesc Types    These entities represent types
 * <longer description follows>
 */
trait Types extends base.Types { self: Universe =>
  /** @group Types */
  override type TypeRef >: Null <: Type with TypeRefApi




            If you set the group,
          all overrides inherit that.
Groups




         Au revoir, api/extractors!
Skip packages
●   Do we want to expose scala.reflect.internal?


    scaladoc -skip-packages scala.reflect.internal:<pack2>:...

    <scaladoc ...
      skipPackages="scala.reflect.internal"/>
Links
●   link anything in the scaladoc pages
    –   classes, traits, objects, types
    –   methods, values, overloeded methods
Links



scala   .   collection     .     List   #   apply
Links



scala   .       collection       .         List   #   unapply




            Separators?
            Both # and . are valid separators
Links



scala   .       collection      .         List        #          unapply




            Class List or object List?
             – backtracking (only the object has method apply)
             – disambiguation
              – List$ points to the object
              – List! points to the class
Links



scala   .   collection     .        List        #      unapply




            Overloaded? Use full signature followed by *.
            – the signature generated by scaladoc
Thank you!
●   2.10 scaladoc new features
    –   @inheritdoc
    –   Diagrams
    –   @template / @documentable
    –   Groups
    –   Skip packages
    –   Links

                                Everything is in
                         pull request 925 on github:
                   https://github.com/scala/scala/pull/925
                                (and a lot more)

More Related Content

Similar to Scaladoc for reflection

Scala overview
Scala overviewScala overview
Scala overview
Steve Min
Β 
scalaliftoff2009.pdf
scalaliftoff2009.pdfscalaliftoff2009.pdf
scalaliftoff2009.pdf
Hiroshi Ono
Β 
scalaliftoff2009.pdf
scalaliftoff2009.pdfscalaliftoff2009.pdf
scalaliftoff2009.pdf
Hiroshi Ono
Β 
scalaliftoff2009.pdf
scalaliftoff2009.pdfscalaliftoff2009.pdf
scalaliftoff2009.pdf
Hiroshi Ono
Β 
scalaliftoff2009.pdf
scalaliftoff2009.pdfscalaliftoff2009.pdf
scalaliftoff2009.pdf
Hiroshi Ono
Β 
Java Serialization Facts and Fallacies
Java Serialization Facts and FallaciesJava Serialization Facts and Fallacies
Java Serialization Facts and Fallacies
Roman Elizarov
Β 
Ch.03 - Class Diagram_1 OBJECT ORIENTED ANALYSIS AND DESIGN [O] .pptx
Ch.03 - Class Diagram_1 OBJECT ORIENTED ANALYSIS AND DESIGN [O] .pptxCh.03 - Class Diagram_1 OBJECT ORIENTED ANALYSIS AND DESIGN [O] .pptx
Ch.03 - Class Diagram_1 OBJECT ORIENTED ANALYSIS AND DESIGN [O] .pptx
SohagSrz
Β 
Martin Odersky - Evolution of Scala
Martin Odersky - Evolution of ScalaMartin Odersky - Evolution of Scala
Martin Odersky - Evolution of Scala
Scala Italy
Β 
An Introduction to Scala - Blending OO and Functional Paradigms
An Introduction to Scala - Blending OO and Functional ParadigmsAn Introduction to Scala - Blending OO and Functional Paradigms
An Introduction to Scala - Blending OO and Functional Paradigms
Miles Sabin
Β 

Similar to Scaladoc for reflection (20)

Oracle Objects And Transactions
Oracle Objects And TransactionsOracle Objects And Transactions
Oracle Objects And Transactions
Β 
Spark real world use cases and optimizations
Spark real world use cases and optimizationsSpark real world use cases and optimizations
Spark real world use cases and optimizations
Β 
Scala Days San Francisco
Scala Days San FranciscoScala Days San Francisco
Scala Days San Francisco
Β 
Scala overview
Scala overviewScala overview
Scala overview
Β 
Knolx Session: Introducing Extractors in Scala
Knolx Session: Introducing Extractors in ScalaKnolx Session: Introducing Extractors in Scala
Knolx Session: Introducing Extractors in Scala
Β 
A Tour Of Scala
A Tour Of ScalaA Tour Of Scala
A Tour Of Scala
Β 
A Deep Dive Into Spark
A Deep Dive Into SparkA Deep Dive Into Spark
A Deep Dive Into Spark
Β 
Scala.pdf
Scala.pdfScala.pdf
Scala.pdf
Β 
scalaliftoff2009.pdf
scalaliftoff2009.pdfscalaliftoff2009.pdf
scalaliftoff2009.pdf
Β 
scalaliftoff2009.pdf
scalaliftoff2009.pdfscalaliftoff2009.pdf
scalaliftoff2009.pdf
Β 
scalaliftoff2009.pdf
scalaliftoff2009.pdfscalaliftoff2009.pdf
scalaliftoff2009.pdf
Β 
scalaliftoff2009.pdf
scalaliftoff2009.pdfscalaliftoff2009.pdf
scalaliftoff2009.pdf
Β 
Spark - The Ultimate Scala Collections by Martin Odersky
Spark - The Ultimate Scala Collections by Martin OderskySpark - The Ultimate Scala Collections by Martin Odersky
Spark - The Ultimate Scala Collections by Martin Odersky
Β 
Introduction to Scala | Big Data Hadoop Spark Tutorial | CloudxLab
Introduction to Scala | Big Data Hadoop Spark Tutorial | CloudxLabIntroduction to Scala | Big Data Hadoop Spark Tutorial | CloudxLab
Introduction to Scala | Big Data Hadoop Spark Tutorial | CloudxLab
Β 
Java Serialization Facts and Fallacies
Java Serialization Facts and FallaciesJava Serialization Facts and Fallacies
Java Serialization Facts and Fallacies
Β 
Introduction to Scala
Introduction to ScalaIntroduction to Scala
Introduction to Scala
Β 
Ch.03 - Class Diagram_1 OBJECT ORIENTED ANALYSIS AND DESIGN [O] .pptx
Ch.03 - Class Diagram_1 OBJECT ORIENTED ANALYSIS AND DESIGN [O] .pptxCh.03 - Class Diagram_1 OBJECT ORIENTED ANALYSIS AND DESIGN [O] .pptx
Ch.03 - Class Diagram_1 OBJECT ORIENTED ANALYSIS AND DESIGN [O] .pptx
Β 
Unit 1 notes.pdf
Unit 1 notes.pdfUnit 1 notes.pdf
Unit 1 notes.pdf
Β 
Martin Odersky - Evolution of Scala
Martin Odersky - Evolution of ScalaMartin Odersky - Evolution of Scala
Martin Odersky - Evolution of Scala
Β 
An Introduction to Scala - Blending OO and Functional Paradigms
An Introduction to Scala - Blending OO and Functional ParadigmsAn Introduction to Scala - Blending OO and Functional Paradigms
An Introduction to Scala - Blending OO and Functional Paradigms
Β 

Recently uploaded

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
Β 

Recently uploaded (20)

Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
Β 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Β 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
Β 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
Β 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
Β 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
Β 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
Β 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
Β 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
Β 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
Β 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
Β 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
Β 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
Β 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Β 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
Β 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
Β 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
Β 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
Β 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
Β 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
Β 

Scaladoc for reflection

  • 1. Scaladoc for reflection (new features in 2.10) Vlad Ureche 19th of July 2012
  • 2. Outline ● 2.10 scaladoc new features – @inheritdoc – Diagrams – @template (or @documentable) – Groups – Skip packages – Links
  • 3. @inheritdoc trait Base { /** Type represents a scala type. */ type Type < : TypeBase } trait Api { /** @inheritdoc * * More details added later. */ abstract class Type ... }
  • 4. @inheritdoc Comment inheritance
  • 5. Diagrams ● Two types – inheritance diagrams ● contain superclasses, subclasses and implicits ● generated by default for classes and traits – content diagrams ● classes/traits/objects contained ● generated by default for packages and objects ● Oh noes – trait Base will only get an inheritance diagram, no contents :((
  • 6. Diagrams ● You can override default behavior – @inheritanceDiagram – @contentDiagram – add the annotation to get the diagram – add hideDiagram to get rid of the diagram – undesirable node? hideNodes "*internal*" – undesirable edge? hideEdges("*A" -> "*B")
  • 7. Diagrams /** Description of the base trait * @contentDiagram * @inheritanceDiagram hideDiagram */ trait Base { /** Type represents a scala type. */ type Type < : TypeBase }
  • 8. Diagrams Try clicking Type. Oh noes, it doesn't work! Type is an abstract type
  • 9. @template / @documentable ● Add this to your {abstract,alias} type – to get a page for the type – to get a clickable node in the template
  • 10. @template / @documentable trait Base { /** Type represents a scala type. * @template */ type Type < : TypeBase }
  • 11. @template / @documentable trait Base { /** Type represents a scala type. * @template */ type Type < : TypeBase }
  • 12. @template Also finds values and treats them as companion objects CLICK
  • 13. Groups ● scala.reflect.api.Types defines 46 types – useful types (Type, TypeRef, …) – classes that give the methods (TypeRefApi, ...) – extractors (TypeRefExtractor, …) ● wouldn't it be nice to group them?
  • 14. Groups package scala.reflect package api /** * @groupdesc Types These entities represent types * <longer description follows> */ trait Types extends base.Types { self: Universe => /** @group Types */ override type TypeRef >: Null <: Type with TypeRefApi If you set the group, all overrides inherit that.
  • 15. Groups Au revoir, api/extractors!
  • 16. Skip packages ● Do we want to expose scala.reflect.internal? scaladoc -skip-packages scala.reflect.internal:<pack2>:... <scaladoc ... skipPackages="scala.reflect.internal"/>
  • 17. Links ● link anything in the scaladoc pages – classes, traits, objects, types – methods, values, overloeded methods
  • 18. Links scala . collection . List # apply
  • 19. Links scala . collection . List # unapply Separators? Both # and . are valid separators
  • 20. Links scala . collection . List # unapply Class List or object List? – backtracking (only the object has method apply) – disambiguation – List$ points to the object – List! points to the class
  • 21. Links scala . collection . List # unapply Overloaded? Use full signature followed by *. – the signature generated by scaladoc
  • 22. Thank you! ● 2.10 scaladoc new features – @inheritdoc – Diagrams – @template / @documentable – Groups – Skip packages – Links Everything is in pull request 925 on github: https://github.com/scala/scala/pull/925 (and a lot more)