Epydoc API Documentation Extraction in Python Edward Loper.

Slides:



Advertisements
Similar presentations
XML: Extensible Markup Language
Advertisements

1 Programming for Engineers in Python Autumn Lecture 5: Object Oriented Programming.
Visual Web Information Extraction With Lixto Robert Baumgartner Sergio Flesca Georg Gottlob.
16-Jun-15 javadoc. 2 Javadoc placement javadoc comments begin with /** and end with */ In a javadoc comment, a * at the beginning of the line is not part.
OOP in Java Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Executable XML Present by 吳昆澤. Outline  Introduction  Simkin  Jelly  o:XML  Conclusion.
Scott Grissom, copyright 2004Ch 3: Java Features Slide 1 Why Java? It is object-oriented provides many ready to use classes platform independent modern.
ASP.NET Programming with C# and SQL Server First Edition
1 Chapter 11 Developing Custom Help. 11 Chapter Objectives Use HTML to create customized Help topics for an application Use the HTML Help Workshop to.
Concordia University Department of Computer Science and Software Engineering Click to edit Master title style ADVANCED PROGRAMING PRACTICES API documentation.
1 Documenting with Javadoc CS 3331 Fall 2009 How to Write Doc Comments for the Javadoc TM Tool available from java.sun.com.
GANGA Release Strategy Documentation Tools GANGA Workshop, April 2004, CERN Chun Lik Tan (Alvin) - Birmingham GANGA Workshop,
3.1 Documentation & Java Language Elements Purpose of documentation Assist the programmer with developing the program Assist other programers who.
Aurora: A Conceptual Model for Web-content Adaptation to Support the Universal Accessibility of Web-based Services Anita W. Huang, Neel Sundaresan Presented.
XForms: A case study Rajiv Shivane & Pavitar Singh.
Overview of Previous Lesson(s) Over View  ASP.NET Pages  Modular in nature and divided into the core sections  Page directives  Code Section  Page.
Lecture 8 Inheritance Richard Gesick. 2 OBJECTIVES How inheritance promotes software reusability. The concepts of base classes and derived classes. To.
Introduction to XML cs3505. References –I got most of this presentation from this site –O’reilly tutorials.
1 v1.6 08/02/2006 Overview of Eclipse Lectures 1.Overview 2.Installing and Running 3.Building and Running Java Classes 4.Refactoring 5.Debugging 6.Testing.
1 Web-Enabled Decision Support Systems Objects and Procedures Don McLaughlin IE 423 Design of Decision Support Systems (304)
CNIT 133 Interactive Web Pags – JavaScript and AJAX JavaScript Environment.
JavaDoc1 JavaDoc DEPARTMENT OF COMPUTER SCIENCE AND SOFTWARE ENGINEERING CONCORDIA UNIVERSITY July 24, 2006 by Emil Vassev & Joey Paquet revision 1.2 –
Writing JavaDocs Mimi Opkins CECS 274 Copyright (c) Pearson All rights reserved.
Program documentation using the Javadoc tool 1 Program documentation Using the Javadoc tool.
JSTL, XML and XSLT An introduction to JSP Standard Tag Library and XML/XSLT transformation for Web layout.
XSLT Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University.
1 Documenting with Javadoc. 2 Motivation  Why document programs? To make it easy to understand, e.g., for reuse and maintenance  What to document? Interface:
1 SystemVerilog Enhancement Requests Daniel Schostak Principal Engineer February 26 th 2010.
Javadoc: Advanced Features & Limitations Presented By: Wes Toland.
INTERFACES More OO Concepts. Interface Topics Using an interface Interface details –syntax –restrictions Create your own interface Remember polymorphism.
Javadoc Comments.  Java API has a documentation tool called javadoc  The javadoc tool is used on the source code embedded with javadoc-style comments.
Software Documentation Section 5.5 ALBING’s Section JIA’s Appendix B JIA’s.
Javadoc A very short tutorial. What is it A program that automatically generates documentation of your Java classes in a standard format For each X.java.
Topic 1 Object Oriented Programming. 1-2 Objectives To review the concepts and terminology of object-oriented programming To discuss some features of.
Documentation Dr. Andrew Wallace PhD BEng(hons) EurIng
Python Functions.
1 CSC/ECE 517 Fall 2010 Lec. 3 Overview of Eclipse Lectures Lecture 2 “Lecture 0” Lecture 3 1.Overview 2.Installing and Running 3.Building and Running.
Programmeren 1 6 september 2010 HOORCOLLEGE 2: INTERACTIE EN CONDITIES PROGRAMMEREN 1 6 SEPTEMBER 2009 Software Systems - Programming1 Programming.
Overview The Basics – Python classes and objects Procedural vs OO Programming Entity modelling Operations / methods Program flow OOP Concepts and user-defined.
COP INTERMEDIATE JAVA Designing Classes. Class Template or blueprint for creating objects. Their definition includes the list of properties (fields)
Page 1 – Autumn 2009Steffen Vissing Andersen SDJ I1, Autumn 2009 Agenda: Java API Documentation Code Documenting (in javadoc format) Debugging.
1 Documenting with Javadoc CS 3331 Section and Appendix B of [Jia03] How to Write Doc Comments for the Javadoc TM Tool available from
Software Reuse Course: # The Johns-Hopkins University Montgomery County Campus Fall 2000 Session 4 Lecture # 3 - September 28, 2004.
Inheritance and Class Hierarchies Chapter 3. Chapter 3: Inheritance and Class Hierarchies2 Chapter Objectives To understand inheritance and how it facilitates.
Inheritance and Class Hierarchies Chapter 3. Chapter Objectives  To understand inheritance and how it facilitates code reuse  To understand how Java.
TeachJava! 2003 Corky Cartwright Dung Nguyen Stephen Wong Charlie Reis, James Hsia, Peter Centgraf.
Rich Internet Applications 2. Core JavaScript. The importance of JavaScript Many choices open to the developer for server-side Can choose server technology.
1 Java Server Pages A Java Server Page is a file consisting of HTML or XML markup into which special tags and code blocks are inserted When the page is.
 Packages:  Scrapy, Beautiful Soup  Scrapy  Website  
21. PHP Classes To define a class, use the keyword class followed by the name and a block with the properties and method definitions Properties are declared.
PHP Reusing Code and Writing Functions 1. Function = a self-contained module of code that: Declares a calling interface – prototype! Performs some task.
10 Copyright © 2004, Oracle. All rights reserved. Building ADF View Components.
Principles of Programming. Achieving an Object-Oriented Design  Abstraction and Information Hiding  Object-Oriented Design  Functional Decomposition.
DataGrid is a project funded by the European Commission under contract IST EDG Baseline API Document Document build description and current.
1 Documenting with Javadoc How to Write Doc Comments for the Javadoc TM Tool available from java.sun.com.
1 Model Driven Health Tools Design and Implementation of CDA Templates Dave Carlson Contractor to CHIO
Today Javadoc. Packages and static import. Viewing API source code. Upcoming Topics: –protected access modifier –Using the debugger in Eclipse –JUnit testing.
Rendering XML Documents ©NIITeXtensible Markup Language/Lesson 5/Slide 1 of 46 Objectives In this session, you will learn to: * Define rendering * Identify.
Variable Scope & Lifetime
Advanced Programing practices
More Sophisticated Behavior
“Under the hood”: Angry Birds Maze
Core WG Meeting November 16th, 2017.
Database Processing with XML
Python Classes By Craig Pennell.
Chapter 6 Methods: A Deeper Look
WEB PROGRAMMING JavaScript.
Interfaces.
Advanced Programing practices
© Sangeeta M Chauhan, Gwalior
Presentation transcript:

Epydoc API Documentation Extraction in Python Edward Loper

Epydoc: Overview Extracts and organizes API documentation for a Python library. Extracts documentation from… Docstrings Inspection Parsed source code And organizes it into a coherent reference... Webpage (HTML) Document (PDF)

API Documentation What it does: Defines the “interface” provided a library. Describes each object defined by the library. Why it’s useful: Explains how to use a library Documents how a library works

Writing API Documentation API documentation is tightly coupled with source code. So it can be difficult to keep it in sync with the implementation. Solution: Keep API documentation in docstrings. A docstring is a string constant at the top of an object’s definition, that is available via inspection.

Documentation Extraction It’s convenient to write API docs in the source code… But it’s not convenient to read them there. Solution: use a tool that… Extracts API docs from the source code Converts them into a readable format

Avoiding Duplication Multiple objects can share the same documentation: Overridden methods Interface implementations Wrapper functions But duplicating their documentation is problematic: It clutters the source code It’s easy for different copies to get out of sync

Avoiding Duplication Epydoc provides 2 mechanisms to avoid duplication: Documentation inheritance: A method without a docstring inherits documentation from the method it overrides. The field: Special markup that can be used to include documentation from any other object.

Epydoc’s Output Epydoc currently supports 2 output formats: Webpage (HTML) Document (LaTeX/DVI/PS/PDF) And one more is in the works: Manpage

Webpage Output: A Quick Tour

Webpage Output: Table of Contents

Webpage Output: Navigation Bar

Webpage Output: Module Documentation

Webpage Output: Class Documentation

Webpage Output: Function Documentation

Docstring Markup Why use markup in docstrings? More expressive power Display medium independence Epydoc supports 4 markup languages: Epytext reStructuredText Markup language declaration: __docformat__ = “restructuredtext” Javadoc Plaintext

Docstring Markup: Epytext A lightweight markup language Easy to write Easy to read as plaintext Easy to understand A conservative markup language Uses common conventions for basic formatting. If encounters unknown formatting, it falls back to verbatim plaintext. Works well with docstrings that were written in plaintext. The default markup language

Docstring Markup: reStructuredText An “easy-to-read, what-you-see-is-what-you-get” markup language Supports a large (and growing) number of constructions Quickly becoming a standard markup language for Python documentation Currently used for PEPs Might be used for the standard library reference documentation in the future.

Fields A “tagged” portion of a docstring that describes a specific property of an object. Descriptions of parameters & return values Information about how objects are organized Metadata about objects Why use fields? Specialized presentation Specialized processing

Fields: Signature Specification Describe individual function/method parameters. Specify a function/method’s type p: …Describes parameter …Describes of the return p: …Describes keyword param p: …Parameter p’s …The return value’s e: …Conditions that cause an exception

Fields: Variable Documentation Describe variables & specify their types Variables can’t define v: …Describes module variable v: …Describes instance variable v: …Describes class variable v: …Variable v’s type In the works: Read pseudo-docstrings for variables (from string literals or specially marked constants).

Fields: Content Organization Specify how objects are g: c 1, …, c n Defines a named collection of related c 1, …, c n Specifies the order in which objects should be cIndicates that an object should not be listed in the documentation

Fields: Metadata & Tagged Information Describe specific aspects of an object. Consistent presentation of information Automatic processing (e.g. creating a bug … etc.

Fields: Create Your Own! Epydoc provides two mechanisms for defining new fields: A special tag: label [, plural-label] A module-level variable: __extra_epydoc_fields__ = [ (tag [, label [, plural-label]]) ]

Extracting Documentation Two prevalent methods for extracting API documentation from Python: Inspection: Import the library, and examine each object’s attributes directly. >>> import zipfile >>> docstring = zipfile.__doc__ >>> … Source code parsing: Parse the library’s source code, and extract relevant information. >>> sourcecode = open(‘zipfile.py’).read() >>> ast = parser.suite(sourcecode) >>> …

Extracting Documentation: Limitations of Parsing Can’t capture the effects of dynamic transformations Metaclasses Namespace manipulation Can’t document non-python modules Extension modules Javadoc modules Non-python base classes for python modules

Extracting Documentation: Limitations of Inspection Some information is unavailable via inspection: What module defines a given function? Which objects are imported vs defined locally? E.g., integer constants Pseudo-docstrings for variables. Can’t document “insecure” code Can’t document modules that perform complex or interactive tasks when imported E.g., opening a Tkinter window

Extracting Documentation Epydoc’s answer: use a hybrid approach! Inspection forms the basis for documentation extraction Inspection gives a more accurate representation of the user-visible behavior. Source code parsing is used to overcome the limitations of inspection, where necessary. Using this hybrid approach, Epydoc can generate comprehensive API documentation for almost any libraries.

Thank you!