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

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Recently uploaded (20)

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
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
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
 
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
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
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
 
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
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
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...
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
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
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 

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)