SlideShare ist ein Scribd-Unternehmen logo
1 von 105
Automating documentation on
JavaScript projects
Marcos Iglesias
@golodhros
My Story
JavaScripTown
Three kinds of code
The Good
New and shiny
Clean and simple
Fully tested
The Bad
Entangled old code
No documentation or comments
Incomplete test suite
The Ugly
Complex structure
Steep learning curve
Fully tested
No documentation
Different challenges
The Challenges
Goal of open-sourcing it
Clear and simple
Well documented
The Challenges
Easy to get lost in the code
Non-obvious relations
High level of indirection
The Challenges
Unfamiliar conceptual elements
New ways of doing things
High level of indirection
Documenting
JavaScript?
JS documentation is
broken
Out of Date
Boring to write
Inconvenient
Comments on the source
Code reviews
Next Up
JSDoc comments
DocStrap
Docco
Choosing
Benefits
Introducing JSDoc
JSDoc is an API
documentation generator
for JavaScript
How does it work?
Add documentation comments
JSDoc tool will scan code and
Generate an HTML documentation website
JSDoc API
Functions
@param
@param { String } name description
@param
@param { (String | Number) } name description
@param
@param { String[] } name description
@return
@return {[type]} description
@private/public
@private or @public
@deprecated
@link
@link {[url] | Link text}
JSDoc Example
JSDoc Example
Modules
@file
Describes a file
@module
Marks file as a module
@requires
Dependencies
@version
@example
@tutorial
@typedef
JSDoc editor Extensions
My Story, continued
(Improvements with JSDoc)
The Good
Favored small and specific methods
Became another review of the code
Helped state which methods were public or private
The Bad
Made clear which methods didn’t belong to each module
Stated the dependencies and links between objects
Avoided re-reading methods
The Ugly
Made it easier to understand the big picture
Helped next developers to understand it
Avoided re-reading of complex pieces
Generating
Documentation
DocStrap
DocStrap is a Bootstrap based
template for JSDoc
Generating Docs - DocStrap
1. Install grunt-jsdoc or gulp-jsdoc3
2. Configure JSDoc tasks
3. Install Docstrap
4. Edit config.json
5. Run task
6. (Debug)
Docco
Docco is a vertical layout
documentation generator with
“prose” and code
Docco comments
//
// comment
Generating Docs - Docco
1. Install Docco as npm package
2. Configure Docco grunt task
3. Add comments for the “Prose” side with //
4. Run grunt task
Which one should
you use?
DocStrap
Complex pieces of code
Is a flow-based program
Explain decisions on your code
Docco
API References
Tutorials and Demos
Customization
Other options
My Story’s End
The Good
JSDoc and Docstrap
Complete customization
Proud of our project!
The Bad
Didn’t want to document it on detail
Ask: How you would I like to learn it?
The Ugly
JSDoc comments were useful
Docco looks like a great candidate
Benefits
Improves communication
about the code
Helps understanding
other’s code
Generates
documentation
Doesn’t get out of date
It’s easy!
Convenient
JSDoc - Resources
API Reference
Use JSDoc: Index
Articles
Dr. Axel Rauschmayer - JSDoc intro
Tom Macwright - In defense of JSDoc
Kaustav Das Modak - JSDoc vs YUIDoc vs Doxx vs Docco
Tricks and Best Practices
Common Pitfalls in JSDoc
DocumentationJS docs
Docco - Resources
Reference
Docco webpage
Articles
Derick Bailey - Annotated Source Code As Documentation, With Docco
Kaustav Das Modak - JSDoc vs YUIDoc vs Doxx vs Docco
Give it a try!
Thanks for Listening!
Q&A
@golodhros
Credits
Imagery
The Good, The Bad and The Ugly Art by Kwad-rat
Sublime Text logo by examinedLiving
Atom Icon by adhmadseleem
Emacs Icon by cg433n
ESLint Icon by Ömer Balyalı

Weitere ähnliche Inhalte

Was ist angesagt?

Bridging the gap between business and technology - Behaviour Driven Developme...
Bridging the gap between business and technology - Behaviour Driven Developme...Bridging the gap between business and technology - Behaviour Driven Developme...
Bridging the gap between business and technology - Behaviour Driven Developme...marcin_pajdzik
 
Phpstorm & Drupal presentation from DrupalCamp NW 2013
Phpstorm & Drupal presentation from DrupalCamp NW 2013Phpstorm & Drupal presentation from DrupalCamp NW 2013
Phpstorm & Drupal presentation from DrupalCamp NW 2013ixisit
 
Behat - human-readable automated testing
Behat - human-readable automated testingBehat - human-readable automated testing
Behat - human-readable automated testingnyccamp
 
Pre-Trained-Language-Models-for-NLU
Pre-Trained-Language-Models-for-NLUPre-Trained-Language-Models-for-NLU
Pre-Trained-Language-Models-for-NLUPOOJA BHOJWANI
 
Introduction to the Dart language
Introduction to the Dart languageIntroduction to the Dart language
Introduction to the Dart languageJana Moudrá
 

Was ist angesagt? (10)

Bridging the gap between business and technology - Behaviour Driven Developme...
Bridging the gap between business and technology - Behaviour Driven Developme...Bridging the gap between business and technology - Behaviour Driven Developme...
Bridging the gap between business and technology - Behaviour Driven Developme...
 
Golang_Perl_Doc
Golang_Perl_DocGolang_Perl_Doc
Golang_Perl_Doc
 
Golang introduction
Golang introductionGolang introduction
Golang introduction
 
Writing Cucumber
Writing CucumberWriting Cucumber
Writing Cucumber
 
Clean code
Clean codeClean code
Clean code
 
Phpstorm & Drupal presentation from DrupalCamp NW 2013
Phpstorm & Drupal presentation from DrupalCamp NW 2013Phpstorm & Drupal presentation from DrupalCamp NW 2013
Phpstorm & Drupal presentation from DrupalCamp NW 2013
 
BDD with Behat
BDD with BehatBDD with Behat
BDD with Behat
 
Behat - human-readable automated testing
Behat - human-readable automated testingBehat - human-readable automated testing
Behat - human-readable automated testing
 
Pre-Trained-Language-Models-for-NLU
Pre-Trained-Language-Models-for-NLUPre-Trained-Language-Models-for-NLU
Pre-Trained-Language-Models-for-NLU
 
Introduction to the Dart language
Introduction to the Dart languageIntroduction to the Dart language
Introduction to the Dart language
 

Andere mochten auch

Built to Last
Built to LastBuilt to Last
Built to LastDan Lynch
 
WebPagetest Power Users - Velocity 2014
WebPagetest Power Users - Velocity 2014WebPagetest Power Users - Velocity 2014
WebPagetest Power Users - Velocity 2014Patrick Meenan
 
Isomorphic JavaScript: #DevBeat Master Class
Isomorphic JavaScript: #DevBeat Master ClassIsomorphic JavaScript: #DevBeat Master Class
Isomorphic JavaScript: #DevBeat Master ClassSpike Brehm
 
Enterprise JavaScript Error Handling (Ajax Experience 2008)
Enterprise JavaScript Error Handling (Ajax Experience 2008)Enterprise JavaScript Error Handling (Ajax Experience 2008)
Enterprise JavaScript Error Handling (Ajax Experience 2008)Nicholas Zakas
 
Scalable JavaScript Application Architecture 2012
Scalable JavaScript Application Architecture 2012Scalable JavaScript Application Architecture 2012
Scalable JavaScript Application Architecture 2012Nicholas Zakas
 
From a monolithic Ruby on Rails app to the JVM
From a monolithic  Ruby on Rails app  to the JVMFrom a monolithic  Ruby on Rails app  to the JVM
From a monolithic Ruby on Rails app to the JVMPhil Calçado
 
Leadership Tools for Better Teams - Personal History Exercise - 20150615
Leadership Tools for Better Teams - Personal History Exercise - 20150615Leadership Tools for Better Teams - Personal History Exercise - 20150615
Leadership Tools for Better Teams - Personal History Exercise - 20150615Joel Wenger
 
Putting Flexbox into Practice
Putting Flexbox into PracticePutting Flexbox into Practice
Putting Flexbox into PracticeZoe Gillenwater
 
Pieces Of Me: My Visual Resume
Pieces Of Me: My Visual ResumePieces Of Me: My Visual Resume
Pieces Of Me: My Visual ResumeMariehdb
 
Navigation Patterns for iOS, Android and More
Navigation Patterns for iOS, Android and MoreNavigation Patterns for iOS, Android and More
Navigation Patterns for iOS, Android and MoreTheresa Neil
 
Abi Jones : Visual Resume
Abi Jones : Visual ResumeAbi Jones : Visual Resume
Abi Jones : Visual ResumeAbi Jones
 
Reorganizing Website Architecture for HTTP/2 and Beyond
Reorganizing Website Architecture for HTTP/2 and BeyondReorganizing Website Architecture for HTTP/2 and Beyond
Reorganizing Website Architecture for HTTP/2 and BeyondKazuho Oku
 

Andere mochten auch (14)

Built to Last
Built to LastBuilt to Last
Built to Last
 
WebPagetest Power Users - Velocity 2014
WebPagetest Power Users - Velocity 2014WebPagetest Power Users - Velocity 2014
WebPagetest Power Users - Velocity 2014
 
Isomorphic JavaScript: #DevBeat Master Class
Isomorphic JavaScript: #DevBeat Master ClassIsomorphic JavaScript: #DevBeat Master Class
Isomorphic JavaScript: #DevBeat Master Class
 
Enterprise JavaScript Error Handling (Ajax Experience 2008)
Enterprise JavaScript Error Handling (Ajax Experience 2008)Enterprise JavaScript Error Handling (Ajax Experience 2008)
Enterprise JavaScript Error Handling (Ajax Experience 2008)
 
Scalable JavaScript Application Architecture 2012
Scalable JavaScript Application Architecture 2012Scalable JavaScript Application Architecture 2012
Scalable JavaScript Application Architecture 2012
 
Teaming Workshops
Teaming WorkshopsTeaming Workshops
Teaming Workshops
 
From a monolithic Ruby on Rails app to the JVM
From a monolithic  Ruby on Rails app  to the JVMFrom a monolithic  Ruby on Rails app  to the JVM
From a monolithic Ruby on Rails app to the JVM
 
Leadership Tools for Better Teams - Personal History Exercise - 20150615
Leadership Tools for Better Teams - Personal History Exercise - 20150615Leadership Tools for Better Teams - Personal History Exercise - 20150615
Leadership Tools for Better Teams - Personal History Exercise - 20150615
 
Putting Flexbox into Practice
Putting Flexbox into PracticePutting Flexbox into Practice
Putting Flexbox into Practice
 
Pieces Of Me: My Visual Resume
Pieces Of Me: My Visual ResumePieces Of Me: My Visual Resume
Pieces Of Me: My Visual Resume
 
Codeware
CodewareCodeware
Codeware
 
Navigation Patterns for iOS, Android and More
Navigation Patterns for iOS, Android and MoreNavigation Patterns for iOS, Android and More
Navigation Patterns for iOS, Android and More
 
Abi Jones : Visual Resume
Abi Jones : Visual ResumeAbi Jones : Visual Resume
Abi Jones : Visual Resume
 
Reorganizing Website Architecture for HTTP/2 and Beyond
Reorganizing Website Architecture for HTTP/2 and BeyondReorganizing Website Architecture for HTTP/2 and Beyond
Reorganizing Website Architecture for HTTP/2 and Beyond
 

Ähnlich wie Talk at FullStack 2016: Automating documentation on JavaScript projects

Code Documentation. That ugly thing...
Code Documentation. That ugly thing...Code Documentation. That ugly thing...
Code Documentation. That ugly thing...Christos Manios
 
Publishing strategies for API documentation
Publishing strategies for API documentationPublishing strategies for API documentation
Publishing strategies for API documentationTom Johnson
 
Concepts and applications of Django.pptx
Concepts and applications of Django.pptxConcepts and applications of Django.pptx
Concepts and applications of Django.pptxsushmitjivtode4
 
Yahoo! Hadoop User Group - May Meetup - Extraordinarily rapid and robust data...
Yahoo! Hadoop User Group - May Meetup - Extraordinarily rapid and robust data...Yahoo! Hadoop User Group - May Meetup - Extraordinarily rapid and robust data...
Yahoo! Hadoop User Group - May Meetup - Extraordinarily rapid and robust data...Hadoop User Group
 
Document Object Model
Document Object ModelDocument Object Model
Document Object Modelchomas kandar
 
Document Object Model
Document Object ModelDocument Object Model
Document Object Modelchomas kandar
 
Introduction to mean and mern || Event by DSC UNIDEB
Introduction to mean and mern || Event by DSC UNIDEBIntroduction to mean and mern || Event by DSC UNIDEB
Introduction to mean and mern || Event by DSC UNIDEBMuhammad Raza
 
Documenting code yapceu2016
Documenting code yapceu2016Documenting code yapceu2016
Documenting code yapceu2016Søren Lund
 
Code Review
Code ReviewCode Review
Code ReviewRavi Raj
 
Introduction to Behavior Driven Development
Introduction to Behavior Driven Development Introduction to Behavior Driven Development
Introduction to Behavior Driven Development Robin O'Brien
 
JavaScript Miller Columns
JavaScript Miller ColumnsJavaScript Miller Columns
JavaScript Miller ColumnsJonathan Fine
 
PRG/420 ENTIRE CLASS UOP TUTORIALS
PRG/420 ENTIRE CLASS UOP TUTORIALSPRG/420 ENTIRE CLASS UOP TUTORIALS
PRG/420 ENTIRE CLASS UOP TUTORIALSSharon Reynolds
 
There is something about JavaScript - Choose Forum 2014
There is something about JavaScript - Choose Forum 2014There is something about JavaScript - Choose Forum 2014
There is something about JavaScript - Choose Forum 2014jbandi
 
PRG 420 Effective Communication - snaptutorial.com
PRG 420 Effective Communication - snaptutorial.comPRG 420 Effective Communication - snaptutorial.com
PRG 420 Effective Communication - snaptutorial.comdonaldzs37
 
Buzzword, How'd They Build That?
Buzzword, How'd They Build That?Buzzword, How'd They Build That?
Buzzword, How'd They Build That?dcoletta
 
Refactoring, 2nd Edition
Refactoring, 2nd EditionRefactoring, 2nd Edition
Refactoring, 2nd Editionjexp
 

Ähnlich wie Talk at FullStack 2016: Automating documentation on JavaScript projects (20)

Code Documentation. That ugly thing...
Code Documentation. That ugly thing...Code Documentation. That ugly thing...
Code Documentation. That ugly thing...
 
Illustrated Code (ASE 2021)
Illustrated Code (ASE 2021)Illustrated Code (ASE 2021)
Illustrated Code (ASE 2021)
 
Publishing strategies for API documentation
Publishing strategies for API documentationPublishing strategies for API documentation
Publishing strategies for API documentation
 
Fewd week4 slides
Fewd week4 slidesFewd week4 slides
Fewd week4 slides
 
Complete resource for web development
Complete resource for web developmentComplete resource for web development
Complete resource for web development
 
Concepts and applications of Django.pptx
Concepts and applications of Django.pptxConcepts and applications of Django.pptx
Concepts and applications of Django.pptx
 
Yahoo! Hadoop User Group - May Meetup - Extraordinarily rapid and robust data...
Yahoo! Hadoop User Group - May Meetup - Extraordinarily rapid and robust data...Yahoo! Hadoop User Group - May Meetup - Extraordinarily rapid and robust data...
Yahoo! Hadoop User Group - May Meetup - Extraordinarily rapid and robust data...
 
Document Object Model
Document Object ModelDocument Object Model
Document Object Model
 
Document Object Model
Document Object ModelDocument Object Model
Document Object Model
 
Introduction to mean and mern || Event by DSC UNIDEB
Introduction to mean and mern || Event by DSC UNIDEBIntroduction to mean and mern || Event by DSC UNIDEB
Introduction to mean and mern || Event by DSC UNIDEB
 
Documenting code yapceu2016
Documenting code yapceu2016Documenting code yapceu2016
Documenting code yapceu2016
 
Code Review
Code ReviewCode Review
Code Review
 
Introduction to Behavior Driven Development
Introduction to Behavior Driven Development Introduction to Behavior Driven Development
Introduction to Behavior Driven Development
 
JavaScript Miller Columns
JavaScript Miller ColumnsJavaScript Miller Columns
JavaScript Miller Columns
 
PRG/420 ENTIRE CLASS UOP TUTORIALS
PRG/420 ENTIRE CLASS UOP TUTORIALSPRG/420 ENTIRE CLASS UOP TUTORIALS
PRG/420 ENTIRE CLASS UOP TUTORIALS
 
There is something about JavaScript - Choose Forum 2014
There is something about JavaScript - Choose Forum 2014There is something about JavaScript - Choose Forum 2014
There is something about JavaScript - Choose Forum 2014
 
PRG 420 Effective Communication - snaptutorial.com
PRG 420 Effective Communication - snaptutorial.comPRG 420 Effective Communication - snaptutorial.com
PRG 420 Effective Communication - snaptutorial.com
 
Grooscript greach
Grooscript greachGrooscript greach
Grooscript greach
 
Buzzword, How'd They Build That?
Buzzword, How'd They Build That?Buzzword, How'd They Build That?
Buzzword, How'd They Build That?
 
Refactoring, 2nd Edition
Refactoring, 2nd EditionRefactoring, 2nd Edition
Refactoring, 2nd Edition
 

Kürzlich hochgeladen

AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesVictorSzoltysek
 
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburgmasabamasaba
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension AidPhilip Schwarz
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...SelfMade bd
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is insideshinachiaurasa2
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrandmasabamasaba
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdfPearlKirahMaeRagusta1
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024Mind IT Systems
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech studentsHimanshiGarg82
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...masabamasaba
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionOnePlan Solutions
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Hararemasabamasaba
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfVishalKumarJha10
 

Kürzlich hochgeladen (20)

AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 

Talk at FullStack 2016: Automating documentation on JavaScript projects

Hinweis der Redaktion

  1. Hi, Thanks for coming!! I am super excited about being here at FullStack2016 It has been an amazing conference so far and I hope to contribute to it with my 2 cents My name is Marcos Iglesias and I am here to talk about documenting JavaScript projects
  2. But, first a bit about me: I am Senior Software Engineer at Eventbrite, where I build User Interfaces and Dashboards for our event organizers.
  3. Let’s start off with a story, It is a software story
  4. It all started when they named me Sheriff of JavaScriptTown I didn’t want the job, you know, a city at the edge of technology, with continuous changes, new projects arriving every day and some of them dying of starvation But I had to pay some debts so I was forced to accept the position
  5. Once I became Sheriff, I understood that I would have to deal with three different types of code
  6. The first specimen was the Good code It was new, clean and well-tested code [You know], A Greenfield project, the kind of project we developers dream of working on.
  7. Next up was the Bad code. It was entangled old code without documentation and few, if any, tests. You may have heard its other name: “Legacy Code”
  8. The last code I had to work with was the Ugly It was code that was neither old nor new, and it was hard to understand and hard to learn It was optimized for reusability and fully tested but it didn’t have any documentation
  9. My mission as Sheriff of JSTown was to put them straight and get them into good shape And as you can imagine, working with such different codebases meant different challenges
  10. Let’s talk about the good code first. We wanted to open source it, so it needed to be kept clear and simple. It required good documentation because we wanted a high quality project.
  11. The challenge with the bad code was that it was easy to get lost in it. There were a number of non-obvious or directly misleading relationships between modules, and it featured a high level of indirection
  12. Finally, when working with The Ugly code, I found a lot of new elements and new ways of doing things without a lot of examples to reference. It also featured a high level of indirection and a complicated hierarchy. (It was a tough one)
  13. In all three cases it seemed that I would benefit from some documentation but Software developers do not document their code very often, and that's especially true for JavaScript. It´s a shame because docs are great: - Just writing them is a useful reviewing process - They help other developers as well as your future self - And they amplify the shared code ownership within your team So why don’t we document more?
  14. In my opinion we don’t do it enough because docs are broken (I have worked in a bunch of different places in different countries and really, nobody got it right) Thinking more about it, and in how docs bugged me in my day to day work, I summarized this issue as 3 main problems:
  15. The first is that most of the times, the docs are out of date. A typical problem of documentation is that unless approached with methodology and care, it can easily get out of date. And not only that, when you find out that some docs are out of date you lose confidence in the rest of the docs and you let even more errors slip through unnoticed (Broken windows effect).
  16. Another problem is that docs are boring to write. We are software developers, we like to write code, not docs!
  17. The third problem is that they are really inconvenient, as they usually live far from where they are needed. Sometimes you don’t even know if a piece of documentation exists before you search for it! (context-switching) Taking into account all these problems, I thought about changing my approach and tried another solution:
  18. This isn’t new, right? Adding comments to the source is something we have been doing for a while. That’s true, however, the way we have been writing Javascript has evolved in the last few years. And I think these recent developments could inform our solution to the problem of documentation. The first of these developments is the use of Code Reviews
  19. The fact that the JavaScript community relies on Code Reviews and Pull Requests to monitor the quality of code means that it can also act as an enforcer of up-to-date comments. (This makes sense, right? Pushing the code and the docs in the same review.)
  20. The second big change is the popularity of ESLint. I love ESLint! It has saved me a lot of time just by giving me warnings about typos or errors before I have even saved the code. It’s that effective! Well, now we can enforce comments and also give warnings about malformed comments using Eslint rules
  21. Up until now, we have seen the three kinds of code I met in JavascriptTown and the challenges they presented. We also saw what’s wrong with documentation of JavaScript projects and a possible approach to solving it: writing the docs as comments near the source code In the rest of this talk I will show you how I used this approach to work with those 3 kinds of code: First I will talk about JSDoc comments Then I will show you two popular ways of generating docs: DocStrap and Docco We’ll also see when to choose each one And finally I will talk about the benefits of adding docs into the source code [itself].
  22. Now let me introduce you to JSDoc comments
  23. The first use of this syntax to document JavaScript was in 1999 with the Mozilla project Rhino, that was a JS runtime written in Java.
  24. Let’s see how it works: First we, as developers, add comments on the source code Then we run the JSDoc tool and it gathers all the docs To generate a documentation website with them
  25. JSDoc is based on a series of tags that you fill with information Its syntax and semantics are similar to those of Javadoc, which is used for documenting code written in Java.
  26. I have separated the tags in two groups: those for functions and those for modules
  27. We have @param that is by far the most common and which specifies the input parameters and types of the method. A typical line will include the tag, the type of the variable, the name and a description of it
  28. We also have @return, that follows a similar pattern
  29. [This indicates] Whether the function is private or public This one is important because it defines what comments would go into the docs, as we will see later
  30. If it is deprecated, you can use this tag.
  31. We can add links to references with @link
  32. This is an example of a private function with some input params and a return of type function
  33. Here is another example with a link reference, note how first we have the URL and then the text
  34. Regarding modules or classes, we will add more tags like:
  35. [Use] @file for the file’s description
  36. You can mark files as a module with @module
  37. Or state dependencies with @requires
  38. Use @version to specify versions.
  39. and add examples of use.
  40. You can link to demos with @tutorial by adding the name of the demo page html file
  41. The @typedef tag is useful for documenting custom types, particularly if you wish to refer to them repeatedly on @param or @return tags
  42. Here we have an example of how to document a module
  43. We have a type definition, in this case a D3 selection
  44. Also the description, module name, version, requirements and tutorial file name
  45. And finally an example of use
  46. We also have some help from plugins for our editors Helper plugins for your editor: Sublime Text, Atom, Vim, PyCharm
  47. Sublime Text
  48. Atom
  49. Vim
  50. Emacs
  51. In the case of pyCharm
  52. And Webstorm, JSDoc comments are supported by default
  53. Here we can see how the Sublime Text plugin helps us to fill the info using the tab button Hit the tab key to bounce between the elements we need to fill Note how effectively we are doing a kind of informative type definition
  54. Now let me go back to my 3 friends, and the cat
  55. Back in JavascriptTown, I decided to use JSDoc to document The Good, The Bad and The Ugly codebases
  56. Commenting with JSDoc on the good code... Helped me to keep my methods small Forced me to review my code one more time In general it made me more mindful when writing my code
  57. For the bad code, writing JSDoc comments: Helped me label the methods that didn’t belong to each module Highlighted dependencies between objects And allowed me to avoid re-reading convoluted methods
  58. Lastly, I commented the Ugly code on a top-to-bottom basis, starting with the high level artifacts This process made it easier for me to understand the big picture Helped other developers to understand it And again I saved some reading time and effort.
  59. Cool! Are you still with me? We have seen what JSDoc comments look like, How commenting is a great tool for understanding other people’s code And for communicating about your own code But there is more, with just a little bit of extra work, we can generate docs from those same comments! At Eventbrite we have experimented with two different flavors, One is API-style documentation and the other is a literate programming approach Each one has been useful for different reasons, but the two are not mutually exclusive.
  60. The first flavor I want to talk about is an API-style documentation generator
  61. You could ask why do you need this? Isn’t JSDoc supposed to generate documentation for you? Paradoxically, the default output of JSDoc generated documentation is not really beautiful (Actually, not even the reference docs are pretty in any sense) So we are gonna use DocStrap to create a better looking output for our docs
  62. The process would be something like this: And debug! Yeah, you didn’t really think it was so easy right? Luckily the kind of debugging you will need to do is to fill some missing types or similar easy problems And now we can use eslint rules to validate the comments beforehand Let me show you an example:
  63. This is the main documentation page of Britecharts, that is a reusable charting library based on D3.js we have been working on at Eventbrite. We are now preparing to open source it and this is the main page, basically derived from the README.md file of the repository.
  64. This is the API reference page for one of the components of Britecharts. It has a list of the public methods that the line component exposes on the right sidebar, And it includes descriptions of each one and its parameters. Here we won’t see the methods marked with an @private This is the main page that Docstrap generates for us.
  65. We can add tutorials like this one, that is the demo page for that same Line component
  66. And we can also add as many additional pages like this Getting Started section. It’s pretty neat and complete.
  67. The other docs generation flavor we have tried is Docco This is A project by Jeremy Ashkenas, the creator of coffeescript, backbone.js and underscore.js
  68. It produces this split view with your comments on the left and the code on the right I am sure you have seen this kind of documentation before
  69. Annotated source code of Backbone
  70. Annotated source code of Underscore.js
  71. Annotated source code of Marionette
  72. One of the main critiques of JSDoc is that their comments are too verbose. On the other hand, docco comments are pretty simple:
  73. Simple inline comment
  74. Simple inline comment
  75. The process is pretty standard
  76. Just if you were guessing Here we can see both type of comments working together
  77. So now we’ll see briefly how to choose between these two documentation styles
  78. I would use Docstrap… - When building a project based on an API, when I need a lookup-style documentation - On public-facing projects that need tutorials and demos, it is a good choice - When you need high levels of control and customization (specially on the look and feel side) On the other hand, I would use Docco - When describing complex pieces of code - Or when the code is based on a flow or that’s the thing we want to describe - When explaining decisions in your code is important
  79. If neither of these options fit in your requirements there are more projects
  80. For Sass we have SassDoc if your platform is heavy on sass magic
  81. Also for Css we have DocumentCSS
  82. And it’s counterpart on the JS side
  83. Lastly for React we can use the React-styleguidist project to generate component libraries This list is not comprehensive and new OS projects are appearing every day...
  84. making me think it’s really an exciting time for documentation generators
  85. Now let me tell you what happened at the end of my time as Sheriff of JavaScriptTown, and after a couple of brawls and rough times with those guys
  86. As we saw it before on the Britecharts project, We managed to create great docs with Docstrap for The Good code I was able to customize the docs and I ended up really proud of our project
  87. At first I didn’t want to create docs for the bad code (It didn’t make sense at that point) However, now that this code got refactored, maybe we want to document it I will ask myself: how would I prefer to learn about this system?
  88. Adding comments was useful for me and for the next developers that worked with it If I spend more time working with this codebase, I would probably choose Docco to document it
  89. We’ve arrived at the end of my talk and You have seen how documenting near the source code can help you deal with different kinds of code I showed you 2 styles of creating documentation from comments and how to choose between them Now I want to close this talk enunciating the benefits of following this approach to commenting right in the source code
  90. The first and primary benefit of consistently adding comments is that it helps you communicate about your code. The mere task of having to figure out the comment you will write for a method will help you think about it and clarify its purpose. It also promotes a shared ownership of the code, reducing the ‘bus factor’ problem.
  91. Also, writing comments on other developer’s code helps you understand it because it forces you to find out why something was written in a given way Plus, it helps you dodge some extra reading when you need to work with it
  92. Another benefit is that it generates documentation for you, we just saw two different styles: API-style references of DocStrap split-screen style of Docco
  93. By far my favorite outcome is that this docs don’t get out of date so easily We are going to review the comments alongside the code when doing code reviews, (Also, when you remove code from the repo, the docs go with them!)
  94. Commenting out your methods is not hard; it’s actually easy and fast! Regardless of your code editor, there are helper plugins that help you And this system will be easier to maintain as the comments are close to the source You can also complete this task any time: while building containers in your dev environment, while running your tests or while waiting for your CI tool to finish the build. It’s an easy way to fill your time productively and it has a huge pay-off for your engineering team.
  95. Lastly, having the code explanation near the source code that is being commented is much more convenient. This way, developers won’t need to open a new browser tab to search for a piece of documentation that maybe doesn’t even exist. [Our teams are wasting hours of developer time just in this context-switching.] [Just think of all the hours of developer time wasted on context switching that you can save with my advice!]
  96. Here I leave you some resources about JSDoc
  97. And Docco
  98. I want to encourage you to give it a try! Maybe you can start with a small project or library, adding comments on the important pieces. Use those comments to communicate about your code, generate documentation and keep it as up-to-date as your code is. You will see that it doesn't take too much work to achieve a codebase that you can be proud of!