SlideShare une entreprise Scribd logo
1  sur  32
Télécharger pour lire hors ligne
Refreshing Documentation
 An Introduction to Dexy

       Ana Nelson

           dexy.it


       July 12, 2011
Dexy for Web Apps




• Install Guide
Dexy for Web Apps




• Install Guide
• User Guide
Dexy for Web Apps




• Install Guide
• User Guide
• Developer Docs
The Big Idea




No Dead Code
  • Any code you show comes from a live, runnable file.
  • Any images or output you show comes from running live code.
Benefits




• Correctness
• Maintainability
• Workflow
Tool for the job



Dexy
 • Open Source (mostly MIT, some AGPL)
 • Written in Python
 • Command Line, Text Based
 • * Agnostic
 • My Day Job and my Mission in Life
Demo


What we want to create:
  • Install Guide
  • User Guide
  • Developer Docs
What we need:
  • An App!
  • Install Script
  • Watir Script
An App




web.py todo list app http://webpy.org/src/todo-list/0.3
DB Schema




CREATE TABLE todo (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    title TEXT
);
model.py


import web

db = web.database(dbn= ’ sqlite ’ , db= ’ todo.sqlite3 ’ )

def get_todos():
    return db.select( ’ todo ’ , order= ’ id ’ )

def new_todo(text):
    db.insert( ’ todo ’ , title=text)

def del_todo(id):
    db.delete( ’ todo ’ , where= " id=$id " , vars=locals())
base.html


$def with (page)

<html>
<head>
    <title>Todo list</title>
</head>
<body>

$:page

</body>
</html>
index.html
$def with (todos, form)

<table>
    <tr>
        <th>What to do ?</th>
        <th></th>
    </tr>
$for todo in todos:
    <tr>
        <td>$todo.title</td>
        <td>
            <form action= "/del/$todo.id" method= "post" >
                <input type= "submit" value= "Delete" />
            </form>
        </td>
    </tr>
</table>

<form action= "" method= "post" >
$:form.render()
</form>
todo.py



 """ Basic todo list using webpy 0.3 """
import web
import model

urls = (
     ’ / ’ , ’ Index ’ ,
    ’ /del/(  d+) ’ , ’ Delete ’
)

render = web.template.render( ’ templates ’ , base= ’ base ’ )
todo.py




class Index:

    form = web.form.Form(
        web.form.Textbox( ’ title ’ , web.form.notnull,
            description= " I need to: " , size=75),
        web.form.Button( ’ Add todo ’ ),
    )
todo.py




def GET(self):
     """ Show page """
    todos = model.get_todos()
    form = self.form()
    return render.index(todos, form)
todo.py



def POST(self):
     """ Add new entry """
    form = self.form()
    if not form.validates():
        todos = model.get_todos()
        return render.index(todos, form)
    model.new_todo(form.d.title)
    raise web.seeother( ’ / ’ )
todo.py




class Delete:

    def POST(self, id):
         """ Delete based on ID """
        id = int(id)
        model.del_todo(id)
        raise web.seeother( ’ / ’ )
todo.py




app = web.application(urls, globals())

if __name__ == ’ __main__ ’ :
    app.run()
install script




Install Script
install script




apt-get update
apt-get upgrade -y --force-yes

apt-get install -y python-webpy
apt-get install -y mercurial
apt-get install -y sqlite3
install script




hg clone https://bitbucket.org/ananelson/dexy-examples
cd dexy-examples
cd webpy

sqlite3 todo.sqlite3 < schema.sql

python todo.py
install script




export UBUNTU_AMI= "ami-06ad526f" # natty
cd ~/.ec2
ec2run $UBUNTU_AMI -k $EC2_KEYPAIR 
    -t t1.micro -f ~/dev/dexy-examples/webpy/ubuntu-install.sh
(Make sure to allow access to port 8080 in security group.)
Now What




• We have an app and we have it running.
• We have an install script which we can use to create an install guide.
• Now we need a script to show how the app works.
Watir


• Watir lets us automate the web browser
• Can be integrated with functional tests
• For extra awesomeness, let’s use Watir to take screenshots
watir




require ’rubygems’
require ’safariwatir’

IP_ADDRESS = ENV[ ’EC2_INSTANCE_IP’ ]
PORT = ’8080’
BASE = " http:// #{ IP_ADDRESS } : #{ PORT } / "
watir



We create a reference to the browser:
browser = Watir::Safari.new
And define a helper method to take screenshots:
def take_screenshot(filename)
    sleep(1) # Make sure page is finished loading.
     ‘ screencapture #{ filename } ‘
      ‘ convert -crop 800x500+0+0   #{ filename }    #{ filename } ‘
end
watir

Now we’re ready to go!
browser.goto(BASE)
take_screenshot( " dexy--index.png " )
watir

Let’s enter a TODO:
browser.text_field( :name , " title " ).set( " Prepare Refresh Austin Talk Demo
take_screenshot( " dexy--enter.png " )
watir
Click the ”Add todo” button to add it. We’ll verify that it was actually added.
browser.button( :name , " Add todo " ).click
raise unless browser.html.include?( " <td>Prepare Refresh Austin Talk Demo</td>
take_screenshot( " dexy--add.png " )
watir

And delete it again:
browser.form( :index , 1).submit
take_screenshot( " dexy--delete.png " )
• Now we have screenshots we can use in our documentation, and which
  we can update any time.
• We also know that the steps described in our screenshots WORK.
• Note that we are also validating our install script.
• You will want to return your DB to its original state within your script, or
  have a reset method in your app.

Contenu connexe

Tendances

Python Code Camp for Professionals 1/4
Python Code Camp for Professionals 1/4Python Code Camp for Professionals 1/4
Python Code Camp for Professionals 1/4DEVCON
 
Supercharging WordPress Development - Wordcamp Brighton 2019
Supercharging WordPress Development - Wordcamp Brighton 2019Supercharging WordPress Development - Wordcamp Brighton 2019
Supercharging WordPress Development - Wordcamp Brighton 2019Adam Tomat
 
Python Code Camp for Professionals 2/4
Python Code Camp for Professionals 2/4Python Code Camp for Professionals 2/4
Python Code Camp for Professionals 2/4DEVCON
 
Web Crawling with NodeJS
Web Crawling with NodeJSWeb Crawling with NodeJS
Web Crawling with NodeJSSylvain Zimmer
 
Phpne august-2012-symfony-components-friends
Phpne august-2012-symfony-components-friendsPhpne august-2012-symfony-components-friends
Phpne august-2012-symfony-components-friendsMichael Peacock
 
Python Code Camp for Professionals 4/4
Python Code Camp for Professionals 4/4Python Code Camp for Professionals 4/4
Python Code Camp for Professionals 4/4DEVCON
 
Python Code Camp for Professionals 3/4
Python Code Camp for Professionals 3/4Python Code Camp for Professionals 3/4
Python Code Camp for Professionals 3/4DEVCON
 
An Introduction to WordPress Hooks
An Introduction to WordPress HooksAn Introduction to WordPress Hooks
An Introduction to WordPress HooksAndrew Marks
 
The Coolest Symfony Components you’ve never heard of - DrupalCon 2017
The Coolest Symfony Components you’ve never heard of - DrupalCon 2017The Coolest Symfony Components you’ve never heard of - DrupalCon 2017
The Coolest Symfony Components you’ve never heard of - DrupalCon 2017Ryan Weaver
 
Scalable web application architecture
Scalable web application architectureScalable web application architecture
Scalable web application architecturepostrational
 
Contributing to WordPress Core - Peter Wilson
Contributing to WordPress Core - Peter WilsonContributing to WordPress Core - Peter Wilson
Contributing to WordPress Core - Peter WilsonWordCamp Sydney
 
國民雲端架構 Django + GAE
國民雲端架構 Django + GAE國民雲端架構 Django + GAE
國民雲端架構 Django + GAEWinston Chen
 
Single Page Web Applications with CoffeeScript, Backbone and Jasmine
Single Page Web Applications with CoffeeScript, Backbone and JasmineSingle Page Web Applications with CoffeeScript, Backbone and Jasmine
Single Page Web Applications with CoffeeScript, Backbone and JasminePaulo Ragonha
 
(DEV305) Building Apps with the AWS SDK for PHP | AWS re:Invent 2014
(DEV305) Building Apps with the AWS SDK for PHP | AWS re:Invent 2014(DEV305) Building Apps with the AWS SDK for PHP | AWS re:Invent 2014
(DEV305) Building Apps with the AWS SDK for PHP | AWS re:Invent 2014Amazon Web Services
 
Symfony tips and tricks
Symfony tips and tricksSymfony tips and tricks
Symfony tips and tricksJavier Eguiluz
 
Getting Started with WP-CLI, a tool to automate your life
Getting Started with WP-CLI, a tool to automate your lifeGetting Started with WP-CLI, a tool to automate your life
Getting Started with WP-CLI, a tool to automate your lifeAJ Morris
 

Tendances (20)

Python Code Camp for Professionals 1/4
Python Code Camp for Professionals 1/4Python Code Camp for Professionals 1/4
Python Code Camp for Professionals 1/4
 
jQuery in 15 minutes
jQuery in 15 minutesjQuery in 15 minutes
jQuery in 15 minutes
 
Supercharging WordPress Development - Wordcamp Brighton 2019
Supercharging WordPress Development - Wordcamp Brighton 2019Supercharging WordPress Development - Wordcamp Brighton 2019
Supercharging WordPress Development - Wordcamp Brighton 2019
 
Python Code Camp for Professionals 2/4
Python Code Camp for Professionals 2/4Python Code Camp for Professionals 2/4
Python Code Camp for Professionals 2/4
 
Web Crawling with NodeJS
Web Crawling with NodeJSWeb Crawling with NodeJS
Web Crawling with NodeJS
 
Vuejs testing
Vuejs testingVuejs testing
Vuejs testing
 
Phpne august-2012-symfony-components-friends
Phpne august-2012-symfony-components-friendsPhpne august-2012-symfony-components-friends
Phpne august-2012-symfony-components-friends
 
Python Code Camp for Professionals 4/4
Python Code Camp for Professionals 4/4Python Code Camp for Professionals 4/4
Python Code Camp for Professionals 4/4
 
Python Code Camp for Professionals 3/4
Python Code Camp for Professionals 3/4Python Code Camp for Professionals 3/4
Python Code Camp for Professionals 3/4
 
An Introduction to WordPress Hooks
An Introduction to WordPress HooksAn Introduction to WordPress Hooks
An Introduction to WordPress Hooks
 
The Coolest Symfony Components you’ve never heard of - DrupalCon 2017
The Coolest Symfony Components you’ve never heard of - DrupalCon 2017The Coolest Symfony Components you’ve never heard of - DrupalCon 2017
The Coolest Symfony Components you’ve never heard of - DrupalCon 2017
 
Scalable web application architecture
Scalable web application architectureScalable web application architecture
Scalable web application architecture
 
Contributing to WordPress Core - Peter Wilson
Contributing to WordPress Core - Peter WilsonContributing to WordPress Core - Peter Wilson
Contributing to WordPress Core - Peter Wilson
 
國民雲端架構 Django + GAE
國民雲端架構 Django + GAE國民雲端架構 Django + GAE
國民雲端架構 Django + GAE
 
Play á la Rails
Play á la RailsPlay á la Rails
Play á la Rails
 
Single Page Web Applications with CoffeeScript, Backbone and Jasmine
Single Page Web Applications with CoffeeScript, Backbone and JasmineSingle Page Web Applications with CoffeeScript, Backbone and Jasmine
Single Page Web Applications with CoffeeScript, Backbone and Jasmine
 
Play!ng with scala
Play!ng with scalaPlay!ng with scala
Play!ng with scala
 
(DEV305) Building Apps with the AWS SDK for PHP | AWS re:Invent 2014
(DEV305) Building Apps with the AWS SDK for PHP | AWS re:Invent 2014(DEV305) Building Apps with the AWS SDK for PHP | AWS re:Invent 2014
(DEV305) Building Apps with the AWS SDK for PHP | AWS re:Invent 2014
 
Symfony tips and tricks
Symfony tips and tricksSymfony tips and tricks
Symfony tips and tricks
 
Getting Started with WP-CLI, a tool to automate your life
Getting Started with WP-CLI, a tool to automate your lifeGetting Started with WP-CLI, a tool to automate your life
Getting Started with WP-CLI, a tool to automate your life
 

En vedette

Marton Zsolt: Típustanok
Marton Zsolt: TípustanokMarton Zsolt: Típustanok
Marton Zsolt: TípustanokSinka Csaba
 
Banki Információk és Forrásai
Banki Információk és ForrásaiBanki Információk és Forrásai
Banki Információk és Forrásaiitp
 
Házas szertartás
Házas szertartásHázas szertartás
Házas szertartásdbotond13
 
Durkó Anett előadása
Durkó Anett előadásaDurkó Anett előadása
Durkó Anett előadásaSinka Csaba
 
Építsd fel az életed
Építsd fel az életedÉpítsd fel az életed
Építsd fel az életedSinka Csaba
 
Betegségmegelőzés
BetegségmegelőzésBetegségmegelőzés
BetegségmegelőzésSinka Csaba
 
Dexy on rails
Dexy on railsDexy on rails
Dexy on railsananelson
 
Hányféleképpen vagy intelligens?
Hányféleképpen vagy intelligens?Hányféleképpen vagy intelligens?
Hányféleképpen vagy intelligens?Sinka Csaba
 
Testvérek a Bibliában
Testvérek a BibliábanTestvérek a Bibliában
Testvérek a BibliábanSinka Csaba
 
Boldogmondások (The Message)
Boldogmondások (The Message)Boldogmondások (The Message)
Boldogmondások (The Message)Sinka Csaba
 
2009 a Kispesti Baptista Gyülekezetben
2009 a Kispesti Baptista Gyülekezetben2009 a Kispesti Baptista Gyülekezetben
2009 a Kispesti Baptista GyülekezetbenSinka Csaba
 
Személyiség és egészségpszichológia
Személyiség és egészségpszichológiaSzemélyiség és egészségpszichológia
Személyiség és egészségpszichológiamalacsik
 
棉花的成長史
棉花的成長史棉花的成長史
棉花的成長史huii0311
 
Gyökössy Endre: Boldogmondások
Gyökössy Endre: BoldogmondásokGyökössy Endre: Boldogmondások
Gyökössy Endre: BoldogmondásokSylvi O.
 

En vedette (20)

Marton Zsolt: Típustanok
Marton Zsolt: TípustanokMarton Zsolt: Típustanok
Marton Zsolt: Típustanok
 
Banki Információk és Forrásai
Banki Információk és ForrásaiBanki Információk és Forrásai
Banki Információk és Forrásai
 
Steve's Diva
Steve's DivaSteve's Diva
Steve's Diva
 
The Sound Of Light
The Sound Of LightThe Sound Of Light
The Sound Of Light
 
Házas szertartás
Házas szertartásHázas szertartás
Házas szertartás
 
Socialización
SocializaciónSocialización
Socialización
 
Durkó Anett előadása
Durkó Anett előadásaDurkó Anett előadása
Durkó Anett előadása
 
51. zsoltár
51. zsoltár51. zsoltár
51. zsoltár
 
Építsd fel az életed
Építsd fel az életedÉpítsd fel az életed
Építsd fel az életed
 
нэг
нэгнэг
нэг
 
Betegségmegelőzés
BetegségmegelőzésBetegségmegelőzés
Betegségmegelőzés
 
Dexy on rails
Dexy on railsDexy on rails
Dexy on rails
 
Hányféleképpen vagy intelligens?
Hányféleképpen vagy intelligens?Hányféleképpen vagy intelligens?
Hányféleképpen vagy intelligens?
 
Testvérek a Bibliában
Testvérek a BibliábanTestvérek a Bibliában
Testvérek a Bibliában
 
Boldogmondások (The Message)
Boldogmondások (The Message)Boldogmondások (The Message)
Boldogmondások (The Message)
 
2009 a Kispesti Baptista Gyülekezetben
2009 a Kispesti Baptista Gyülekezetben2009 a Kispesti Baptista Gyülekezetben
2009 a Kispesti Baptista Gyülekezetben
 
Merj szeretni!
Merj szeretni!Merj szeretni!
Merj szeretni!
 
Személyiség és egészségpszichológia
Személyiség és egészségpszichológiaSzemélyiség és egészségpszichológia
Személyiség és egészségpszichológia
 
棉花的成長史
棉花的成長史棉花的成長史
棉花的成長史
 
Gyökössy Endre: Boldogmondások
Gyökössy Endre: BoldogmondásokGyökössy Endre: Boldogmondások
Gyökössy Endre: Boldogmondások
 

Similaire à Refresh Austin - Intro to Dexy

09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)Igor Bronovskyy
 
TurboGears2 Pluggable Applications
TurboGears2 Pluggable ApplicationsTurboGears2 Pluggable Applications
TurboGears2 Pluggable ApplicationsAlessandro Molina
 
Javascript first-class citizenery
Javascript first-class citizeneryJavascript first-class citizenery
Javascript first-class citizenerytoddbr
 
Test-driven Development with Drupal and Codeception (DrupalCamp Brighton)
Test-driven Development with Drupal and Codeception (DrupalCamp Brighton)Test-driven Development with Drupal and Codeception (DrupalCamp Brighton)
Test-driven Development with Drupal and Codeception (DrupalCamp Brighton)Cogapp
 
Writing HTML5 Web Apps using Backbone.js and GAE
Writing HTML5 Web Apps using Backbone.js and GAEWriting HTML5 Web Apps using Backbone.js and GAE
Writing HTML5 Web Apps using Backbone.js and GAERon Reiter
 
Dev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDBDev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDBMongoDB
 
WordPress as the Backbone(.js)
WordPress as the Backbone(.js)WordPress as the Backbone(.js)
WordPress as the Backbone(.js)Beau Lebens
 
Mini Curso Django Ii Congresso Academico Ces
Mini Curso Django Ii Congresso Academico CesMini Curso Django Ii Congresso Academico Ces
Mini Curso Django Ii Congresso Academico CesLeonardo Fernandes
 
Charla EHU Noviembre 2014 - Desarrollo Web
Charla EHU Noviembre 2014 - Desarrollo WebCharla EHU Noviembre 2014 - Desarrollo Web
Charla EHU Noviembre 2014 - Desarrollo WebMikel Torres Ugarte
 
CodeIgniter PHP MVC Framework
CodeIgniter PHP MVC FrameworkCodeIgniter PHP MVC Framework
CodeIgniter PHP MVC FrameworkBo-Yi Wu
 
GDG Addis - An Introduction to Django and App Engine
GDG Addis - An Introduction to Django and App EngineGDG Addis - An Introduction to Django and App Engine
GDG Addis - An Introduction to Django and App EngineYared Ayalew
 
20130528 solution linux_frousseau_nopain_webdev
20130528 solution linux_frousseau_nopain_webdev20130528 solution linux_frousseau_nopain_webdev
20130528 solution linux_frousseau_nopain_webdevFrank Rousseau
 
An Introduction to Tornado
An Introduction to TornadoAn Introduction to Tornado
An Introduction to TornadoGavin Roy
 
Zend Framework 1.9 Setup & Using Zend_Tool
Zend Framework 1.9 Setup & Using Zend_ToolZend Framework 1.9 Setup & Using Zend_Tool
Zend Framework 1.9 Setup & Using Zend_ToolGordon Forsythe
 
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)Doris Chen
 

Similaire à Refresh Austin - Intro to Dexy (20)

09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
 
Nodejs.meetup
Nodejs.meetupNodejs.meetup
Nodejs.meetup
 
Codegnitorppt
CodegnitorpptCodegnitorppt
Codegnitorppt
 
TurboGears2 Pluggable Applications
TurboGears2 Pluggable ApplicationsTurboGears2 Pluggable Applications
TurboGears2 Pluggable Applications
 
Javascript first-class citizenery
Javascript first-class citizeneryJavascript first-class citizenery
Javascript first-class citizenery
 
Test-driven Development with Drupal and Codeception (DrupalCamp Brighton)
Test-driven Development with Drupal and Codeception (DrupalCamp Brighton)Test-driven Development with Drupal and Codeception (DrupalCamp Brighton)
Test-driven Development with Drupal and Codeception (DrupalCamp Brighton)
 
Having Fun with Play
Having Fun with PlayHaving Fun with Play
Having Fun with Play
 
Writing HTML5 Web Apps using Backbone.js and GAE
Writing HTML5 Web Apps using Backbone.js and GAEWriting HTML5 Web Apps using Backbone.js and GAE
Writing HTML5 Web Apps using Backbone.js and GAE
 
Django crush course
Django crush course Django crush course
Django crush course
 
Dev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDBDev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDB
 
WordPress as the Backbone(.js)
WordPress as the Backbone(.js)WordPress as the Backbone(.js)
WordPress as the Backbone(.js)
 
Mini Curso Django Ii Congresso Academico Ces
Mini Curso Django Ii Congresso Academico CesMini Curso Django Ii Congresso Academico Ces
Mini Curso Django Ii Congresso Academico Ces
 
Charla EHU Noviembre 2014 - Desarrollo Web
Charla EHU Noviembre 2014 - Desarrollo WebCharla EHU Noviembre 2014 - Desarrollo Web
Charla EHU Noviembre 2014 - Desarrollo Web
 
CodeIgniter PHP MVC Framework
CodeIgniter PHP MVC FrameworkCodeIgniter PHP MVC Framework
CodeIgniter PHP MVC Framework
 
实战Ecos
实战Ecos实战Ecos
实战Ecos
 
GDG Addis - An Introduction to Django and App Engine
GDG Addis - An Introduction to Django and App EngineGDG Addis - An Introduction to Django and App Engine
GDG Addis - An Introduction to Django and App Engine
 
20130528 solution linux_frousseau_nopain_webdev
20130528 solution linux_frousseau_nopain_webdev20130528 solution linux_frousseau_nopain_webdev
20130528 solution linux_frousseau_nopain_webdev
 
An Introduction to Tornado
An Introduction to TornadoAn Introduction to Tornado
An Introduction to Tornado
 
Zend Framework 1.9 Setup & Using Zend_Tool
Zend Framework 1.9 Setup & Using Zend_ToolZend Framework 1.9 Setup & Using Zend_Tool
Zend Framework 1.9 Setup & Using Zend_Tool
 
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
 

Dernier

08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
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 2024Results
 
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.pdfsudhanshuwaghmare1
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
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...Drew Madelung
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
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.pptxEarley Information Science
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 

Dernier (20)

08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
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
 
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
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
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...
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
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
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 

Refresh Austin - Intro to Dexy

  • 1. Refreshing Documentation An Introduction to Dexy Ana Nelson dexy.it July 12, 2011
  • 2. Dexy for Web Apps • Install Guide
  • 3. Dexy for Web Apps • Install Guide • User Guide
  • 4. Dexy for Web Apps • Install Guide • User Guide • Developer Docs
  • 5. The Big Idea No Dead Code • Any code you show comes from a live, runnable file. • Any images or output you show comes from running live code.
  • 7. Tool for the job Dexy • Open Source (mostly MIT, some AGPL) • Written in Python • Command Line, Text Based • * Agnostic • My Day Job and my Mission in Life
  • 8. Demo What we want to create: • Install Guide • User Guide • Developer Docs What we need: • An App! • Install Script • Watir Script
  • 9. An App web.py todo list app http://webpy.org/src/todo-list/0.3
  • 10. DB Schema CREATE TABLE todo ( id INTEGER PRIMARY KEY AUTOINCREMENT, title TEXT );
  • 11. model.py import web db = web.database(dbn= ’ sqlite ’ , db= ’ todo.sqlite3 ’ ) def get_todos(): return db.select( ’ todo ’ , order= ’ id ’ ) def new_todo(text): db.insert( ’ todo ’ , title=text) def del_todo(id): db.delete( ’ todo ’ , where= " id=$id " , vars=locals())
  • 12. base.html $def with (page) <html> <head> <title>Todo list</title> </head> <body> $:page </body> </html>
  • 13. index.html $def with (todos, form) <table> <tr> <th>What to do ?</th> <th></th> </tr> $for todo in todos: <tr> <td>$todo.title</td> <td> <form action= "/del/$todo.id" method= "post" > <input type= "submit" value= "Delete" /> </form> </td> </tr> </table> <form action= "" method= "post" > $:form.render() </form>
  • 14. todo.py """ Basic todo list using webpy 0.3 """ import web import model urls = ( ’ / ’ , ’ Index ’ , ’ /del/( d+) ’ , ’ Delete ’ ) render = web.template.render( ’ templates ’ , base= ’ base ’ )
  • 15. todo.py class Index: form = web.form.Form( web.form.Textbox( ’ title ’ , web.form.notnull, description= " I need to: " , size=75), web.form.Button( ’ Add todo ’ ), )
  • 16. todo.py def GET(self): """ Show page """ todos = model.get_todos() form = self.form() return render.index(todos, form)
  • 17. todo.py def POST(self): """ Add new entry """ form = self.form() if not form.validates(): todos = model.get_todos() return render.index(todos, form) model.new_todo(form.d.title) raise web.seeother( ’ / ’ )
  • 18. todo.py class Delete: def POST(self, id): """ Delete based on ID """ id = int(id) model.del_todo(id) raise web.seeother( ’ / ’ )
  • 19. todo.py app = web.application(urls, globals()) if __name__ == ’ __main__ ’ : app.run()
  • 21. install script apt-get update apt-get upgrade -y --force-yes apt-get install -y python-webpy apt-get install -y mercurial apt-get install -y sqlite3
  • 22. install script hg clone https://bitbucket.org/ananelson/dexy-examples cd dexy-examples cd webpy sqlite3 todo.sqlite3 < schema.sql python todo.py
  • 23. install script export UBUNTU_AMI= "ami-06ad526f" # natty cd ~/.ec2 ec2run $UBUNTU_AMI -k $EC2_KEYPAIR -t t1.micro -f ~/dev/dexy-examples/webpy/ubuntu-install.sh (Make sure to allow access to port 8080 in security group.)
  • 24. Now What • We have an app and we have it running. • We have an install script which we can use to create an install guide. • Now we need a script to show how the app works.
  • 25. Watir • Watir lets us automate the web browser • Can be integrated with functional tests • For extra awesomeness, let’s use Watir to take screenshots
  • 26. watir require ’rubygems’ require ’safariwatir’ IP_ADDRESS = ENV[ ’EC2_INSTANCE_IP’ ] PORT = ’8080’ BASE = " http:// #{ IP_ADDRESS } : #{ PORT } / "
  • 27. watir We create a reference to the browser: browser = Watir::Safari.new And define a helper method to take screenshots: def take_screenshot(filename) sleep(1) # Make sure page is finished loading. ‘ screencapture #{ filename } ‘ ‘ convert -crop 800x500+0+0 #{ filename } #{ filename } ‘ end
  • 28. watir Now we’re ready to go! browser.goto(BASE) take_screenshot( " dexy--index.png " )
  • 29. watir Let’s enter a TODO: browser.text_field( :name , " title " ).set( " Prepare Refresh Austin Talk Demo take_screenshot( " dexy--enter.png " )
  • 30. watir Click the ”Add todo” button to add it. We’ll verify that it was actually added. browser.button( :name , " Add todo " ).click raise unless browser.html.include?( " <td>Prepare Refresh Austin Talk Demo</td> take_screenshot( " dexy--add.png " )
  • 31. watir And delete it again: browser.form( :index , 1).submit take_screenshot( " dexy--delete.png " )
  • 32. • Now we have screenshots we can use in our documentation, and which we can update any time. • We also know that the steps described in our screenshots WORK. • Note that we are also validating our install script. • You will want to return your DB to its original state within your script, or have a reset method in your app.