Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Sphinx/docutilsの光と闇

cocoatomo
November 28, 2018

 Sphinx/docutilsの光と闇

cocoatomo

November 28, 2018
Tweet

More Decks by cocoatomo

Other Decks in Programming

Transcript

  1. Sphinx/docutils
    ܕ෇͚ͷޫͱҋ
    @cocoatomo

    View full-size slide

  2. ΞδΣϯμ
    1. ܕͱ͸
    2. Pythonͷܕώϯτ
    3. ޙ෇͚ͷܕ෇͚࡞ۀ
    4. ܕ෇͚ͷҋ
    5. ܕ෇͚ͷޫ
    6. ऴΘΓʹ

    View full-size slide

  3. 1. ܕͱ͸
    • ஋ͷछผ෼ྨ
    • ࣮ߦલʹ൑໌͠ͳ͍ܕʢಈతܕʣ
    • ॊೈͳϓϩάϥϜ͕ॻ͚Δ
    • ॊೈա͗ͯͲΜͳ஋͕དྷΔ͔෼͔Βͳ͍
    • ࣮ߦલʹ൑໌͢Δܕʢ੩తܕʣ
    • ࣮ߦલʹ෦෼తʹόά͕ݕग़Ͱ͖Δ
    • ܕγεςϜ͕ځ۶ͳ͜ͱ΋ʢ΋͏ੲͷ࿩ʣ

    View full-size slide

  4. 2. Pythonͷܕώϯτ
    • ม਺ɺؔ਺ʢύϥϝʔλ&ฦΓ஋ʣʹର͢Δܕࢦఆ
    • ͋͘·ͰΦϓγϣϯ
    • ੩తͳܕղੳπʔϧ͕ར༻/࣮ߦ࣌ʹ͸ແࢹ
    • PEP 484 -- Type Hints
    • PEP 561 -- Distributing and Packaging Type
    Information

    View full-size slide

  5. 3. ޙ෇͚ͷܕ෇͚࡞ۀ
    • ม਺΍ؔ਺ͷ࢖ΘΕํ͔ΒܕΛਪଌ
    • ୅ೖ஋ɺଐੑɺҾ਺ɺฦΓ஋͕୅ೖ͞ΕΔม਺ͳͲ
    • ෳ਺ͷܕ͕༗ΓಘΔ৔߹͸UnionΛ࢖͏
    • Ͳ͏ͯ͠΋ܕ͕෇͚ΒΕͳ͍ͱ͖͸ܕΛແࢹ͢Δ
    • # type: ignoreͱ͍͏ίϝϯτͰແࢹ
    • ಈతʹੜ͑Δଐੑɺ৯͍ҧ͏ϝιουΦʔόʔϥΠυ

    View full-size slide

  6. 4. ܕ෇͚ͷҋ
    • ܕ͕෼͔Βͳ͍
    • ಛʹϑϨʔϜϫʔΫͷ൚༻తͳ࣮૷
    • ઈରʹטΈ߹Θͳ͍ܕ
    • docutils.nodes.Elementͷ__add__ͱ__iadd__
    • Mypy͸Ҿ਺ͷܕ͕ಉ͡Ͱ͋Δ͜ͱΛٻΊΔ
    ͕……

    View full-size slide

  7. __add__ͱ__iadd__

    View full-size slide

  8. 5. ܕ෇͚ͷޫ
    • όά͕ݟ෇͔Δ
    • quote_plusͷฦΓ஋ʢstrʣͷdecodeϝιουΛ
    ݺ΅͏ͱ͢Δ͕ʢPy3ʹ͸ʣͦΜͳ΋ͷ͸ແ͍!!
    • https://github.com/sphinx-doc/sphinx/commit/
    3808405b50503f8902ce6c061272c2e7d1b359
    cc#diff-d0e894e396b3cee20ed52b6be6ad63e6

    View full-size slide

  9. decodeΛ࡟আ

    View full-size slide

  10. 6. ऴΘΓʹ
    • ΈΜͳγϯϓϧͳܕ͕෇͘PythonίʔυΛॻ͜
    ͏ͳ!!
    • ※஫. docutilsʹ΋ޫ͸͋Δ͠ɺSphinxʹ΋ҋ͸͋
    Δ

    View full-size slide