kernel recipes 2016 - kernel documentation: what we have and where it’s going

63
Kernel documentation: what we have and where we’re going Jonathan Corbet [email protected] Kernel Recipes 2016

Upload: anne-nicolas

Post on 09-Jan-2017

274 views

Category:

Software


1 download

TRANSCRIPT

Page 1: Kernel Recipes 2016 - Kernel documentation: what we have and where it’s going

Kernel documentation:what we have and where we’re going

Jonathan [email protected]

Kernel Recipes 2016

Page 2: Kernel Recipes 2016 - Kernel documentation: what we have and where it’s going

Maintainers tend to get to be maintainers because they were good at something else, and not good enough at hiding from the "maintainer" role. There is a paradox here as a maintainer must be good at saying "No", but if they were they might never have agreed to become a maintainer. — Neil Brown

Page 3: Kernel Recipes 2016 - Kernel documentation: what we have and where it’s going

The current state of kernel documentation

Page 4: Kernel Recipes 2016 - Kernel documentation: what we have and where it’s going

The Linux kernel

The core of any Linux system

Some numbers:53,654 files 3,689 directories 63 -day release cycle (+/-) 1,600 developers contributing to each release12,000 changesets (at least) in each release

Page 5: Kernel Recipes 2016 - Kernel documentation: what we have and where it’s going

A huge and fast-moving project!

Page 6: Kernel Recipes 2016 - Kernel documentation: what we have and where it’s going

Kernel documentation

Centered in Documentation/ 2,264 files 228 directories 23MB of material(all excluding Documentation/devicetree)

Also some utilities in scripts/...and arguably stuff in samples/

Page 7: Kernel Recipes 2016 - Kernel documentation: what we have and where it’s going

The two faces of kernel documentation

Ordinary .txt files (2000+ of them)Some are current, comprehensive, and usefulOthers … less so...

Page 8: Kernel Recipes 2016 - Kernel documentation: what we have and where it’s going

The two faces of kernel documentation

Ordinary .txt files (2000+ of them)Some are current, comprehensive, and usefulOthers … less so...

Formatted documentation under DocBook/34 DocBook “template files”Can pull information from the source codeRendered into PDF, HTML, man pages, ...

Page 9: Kernel Recipes 2016 - Kernel documentation: what we have and where it’s going

But wait … there's more …!

Page 10: Kernel Recipes 2016 - Kernel documentation: what we have and where it’s going

Kerneldoc comments

Found throughout the kernel source

/** * list_add - add a new entry * @new: new entry to be added * @head: list head to add it after * * Insert a new entry after the specified head. * This is good for implementing stacks. */

Page 11: Kernel Recipes 2016 - Kernel documentation: what we have and where it’s going

Kerneldoc comments

Found throughout the kernel source

/** * list_add - add a new entry * @new: new entry to be added * @head: list head to add it after * * Insert a new entry after the specified head. * This is good for implementing stacks. */

Page 12: Kernel Recipes 2016 - Kernel documentation: what we have and where it’s going

Kerneldoc comments

Found throughout the kernel source

/** * list_add - add a new entry * @new: new entry to be added * @head: list head to add it after * * Insert a new entry after the specified head. * This is good for implementing stacks. */

Page 13: Kernel Recipes 2016 - Kernel documentation: what we have and where it’s going

Kerneldoc comments

Found throughout the kernel source

/** * list_add - add a new entry * @new: new entry to be added * @head: list head to add it after * * Insert a new entry after the specified head. * This is good for implementing stacks. */

Page 14: Kernel Recipes 2016 - Kernel documentation: what we have and where it’s going

Kerneldoc comments

Found throughout the kernel source

/** * list_add - add a new entry * @new: new entry to be added * @head: list head to add it after * * Insert a new entry after the specified head. * This is good for implementing stacks. */

Page 15: Kernel Recipes 2016 - Kernel documentation: what we have and where it’s going

Kerneldoc comments

Can describe structures as well as functions

Can also contain unattached documentation

The kernel contains about 55,000 of them!

Page 16: Kernel Recipes 2016 - Kernel documentation: what we have and where it’s going

Intelligent design?

There is no overall vision for kernel docsThings get added whenever......and wherever......and forgotten for years.

Page 17: Kernel Recipes 2016 - Kernel documentation: what we have and where it’s going

“Documentation/* is a gigantic mess, currently organized based on where random passers-by put things down last.”— Rob Landley

Page 18: Kernel Recipes 2016 - Kernel documentation: what we have and where it’s going

“Documentation/* is a gigantic mess, currently organized based on where random passers-by put things down last.”— Rob Landley, July, 2007

Page 19: Kernel Recipes 2016 - Kernel documentation: what we have and where it’s going
Page 20: Kernel Recipes 2016 - Kernel documentation: what we have and where it’s going
Page 21: Kernel Recipes 2016 - Kernel documentation: what we have and where it’s going

Intelligent design?

There is no overall vision for kernel docsThings get added whenever......and wherever......and forgotten for years.

No cross-document linkageFew references to other documents at all

Page 22: Kernel Recipes 2016 - Kernel documentation: what we have and where it’s going

Formatted documentation

The real heart of kernel documentation?

Advantages:Much of the documentation is in the sourceEnables creation of integrated documents

...to a pointNumerous output formatsActive interest in improving things

Page 23: Kernel Recipes 2016 - Kernel documentation: what we have and where it’s going

There's a “but” coming...

Page 24: Kernel Recipes 2016 - Kernel documentation: what we have and where it’s going

It's a documentation system written by kernel developers!

Page 25: Kernel Recipes 2016 - Kernel documentation: what we have and where it’s going

How it works

User types “make htmldocs”scripts/docproc parses the template files

<sect1><title>String Conversions</title>!Elib/vsprintf.c!Finclude/linux/kernel.h kstrtol!Finclude/linux/kernel.h kstrtoul!Elib/kstrtox.c

Page 26: Kernel Recipes 2016 - Kernel documentation: what we have and where it’s going

How it works

For each source-code reference:docproc parses the source file for exports

Page 27: Kernel Recipes 2016 - Kernel documentation: what we have and where it’s going

How it works

For each source-code reference:docproc parses the source file for exportskernel-doc parses the source for definitions

Page 28: Kernel Recipes 2016 - Kernel documentation: what we have and where it’s going

How it works

For each source-code reference:docproc parses the source file for exportskernel-doc parses the source for definitionskernel-doc parses it again for documentation

emits DocBook-formatted snippets

Page 29: Kernel Recipes 2016 - Kernel documentation: what we have and where it’s going

How it works

For each source-code reference:docproc parses the source file for exportskernel-doc parses the source for definitionskernel-doc parses it again for documentation

emits DocBook-formatted snippetsdocproc stuffs them into the template

Page 30: Kernel Recipes 2016 - Kernel documentation: what we have and where it’s going

How it works

For each source-code reference:docproc parses the source file for exportskernel-doc parses the source for definitionskernel-doc parses it again for documentation

emits DocBook-formatted snippetsdocproc stuffs them into the templatekernel-doc-xml-ref finds cross-references

only within a single template!template munged appropriately

Page 31: Kernel Recipes 2016 - Kernel documentation: what we have and where it’s going

How it works

For each source-code reference:docproc parses the source file for exportskernel-doc parses the source for definitionskernel-doc parses it again for documentation

emits DocBook-formatted snippetsdocproc stuffs them into the templatekernel-doc-xml-ref finds cross-references

only within a single template!template munged appropriately

xmlto is fed the result

Page 32: Kernel Recipes 2016 - Kernel documentation: what we have and where it’s going

Resulting problems

It's slow

It's brittle

Hard to set up and make work

Ugly output

No formatting within DocBook comments

No integration with the rest of the Documentation/ directory

Page 33: Kernel Recipes 2016 - Kernel documentation: what we have and where it’s going

How can we make things better?

Page 34: Kernel Recipes 2016 - Kernel documentation: what we have and where it’s going

Toward better kernel docs

Clean up the mess

Better formatted outputWith a more rational toolchain

Preserve — or enhance — plain-text access

Page 35: Kernel Recipes 2016 - Kernel documentation: what we have and where it’s going

Recent work

Add markdown processing to kerneldoc comments

(Daniel Vetter, Daniel Cesar Lemes de Paula)Later switched to asciidoc

Page 36: Kernel Recipes 2016 - Kernel documentation: what we have and where it’s going

AsciiDoc in kernel comments

AdvantagesMove more documentation to the sourceAvoid unpleasant DocBook formattingBetter documentation!

Page 37: Kernel Recipes 2016 - Kernel documentation: what we have and where it’s going

AsciiDoc in kernel comments

AdvantagesMove more documentation to the sourceAvoid unpleasant DocBook formattingBetter documentation!

DisadvantagesAdding a new tool to the house of cardsDisagreements between toolsPerformance issuesStill no linkage between documentsRuby dependency

Page 38: Kernel Recipes 2016 - Kernel documentation: what we have and where it’s going

What I wanted to see

Dispense with DocBook entirely!

Use a simple markup processor for everything(Markdown, AsciiDoc, Sphinx, …)Even for “unformatted” docs

Create a single integrated documentation tree

Page 39: Kernel Recipes 2016 - Kernel documentation: what we have and where it’s going

Working solutions should not be blocked in favor of something nicer

that might exist in the future.

Page 40: Kernel Recipes 2016 - Kernel documentation: what we have and where it’s going

...even so...

...one can look around a little more...

Page 41: Kernel Recipes 2016 - Kernel documentation: what we have and where it’s going

Sphinx

A documentation system for Pythonwww.sphinx-doc.org

Based on reStructuredTextYet another simple markup language

Page 42: Kernel Recipes 2016 - Kernel documentation: what we have and where it’s going

Advantages of Sphinx

Designed for documenting code

Designed for large documents...in multiple files

Widely used, well supported

Output to HTML, ePub, PDF...without DocBook or even LaTeX

Page 43: Kernel Recipes 2016 - Kernel documentation: what we have and where it’s going

What happened from there

I posted a proof of conceptdiscussion ensued

Jani Nikula took the POC and ran with it

Consensus formed around this approach

Page 44: Kernel Recipes 2016 - Kernel documentation: what we have and where it’s going

How it works

The kerneldoc comments work as alwaysNo need to change 1000’s of comments

But...Those comments can now contain RST directives!

Page 45: Kernel Recipes 2016 - Kernel documentation: what we have and where it’s going

We also get:

Cross-document cross-references

Function / data structure indexes

Much nicer output

Simpler, faster document build

Page 46: Kernel Recipes 2016 - Kernel documentation: what we have and where it’s going
Page 47: Kernel Recipes 2016 - Kernel documentation: what we have and where it’s going

How it works (continued)

Place an RST document in Documentation/Doesn’t have to be in a specific directory

Add a reference in index.rst

That’s it!

Page 48: Kernel Recipes 2016 - Kernel documentation: what we have and where it’s going
Page 49: Kernel Recipes 2016 - Kernel documentation: what we have and where it’s going

Including kerneldoc comments

Jani wrote a new extension module

Use the following:

.. kernel-doc:: file :export: :internal: :doc: doc-section title :function: functions ...

Page 50: Kernel Recipes 2016 - Kernel documentation: what we have and where it’s going

Including kerneldoc comments

Jani wrote a new extension module

Use the following:

.. kernel-doc:: file :export: :internal: :doc: doc-section title :function: functions ...

Only one of these!

Page 51: Kernel Recipes 2016 - Kernel documentation: what we have and where it’s going

Current status

Merged for 4.8

Sphinx documents for nowKernel documentation HOWTOGPU documentationMedia subsystem

Page 52: Kernel Recipes 2016 - Kernel documentation: what we have and where it’s going

The merge window has been fairly normal, although the patch itself looks somewhat unusual: over 20% of the patch is documentation updates, due to conversion of the drm and media documentation from docbook to the Sphinx doc format.— Linus Torvalds (4.8-rc1 release)

Page 53: Kernel Recipes 2016 - Kernel documentation: what we have and where it’s going

My general impression is that it is now a way easier to maintain the media documentation and make it more consistent than with DocBook. — Mauro Carvalho Chehab

This new documentation format combines the best of two worlds, pretty online browser documentation with almost plain text files, and changes being tracked via git commits.... You got to love it! :-)— Jesper Dangaard Brouer

Page 54: Kernel Recipes 2016 - Kernel documentation: what we have and where it’s going

Coming in 4.9

Documentation/driver-api/Conversion of the device-drivers book(+ various text files)

Page 55: Kernel Recipes 2016 - Kernel documentation: what we have and where it’s going

Documentation/driver-api

Start with DocBook/device-drivers.tmplConvert to several .rst files under driver-api/

Page 56: Kernel Recipes 2016 - Kernel documentation: what we have and where it’s going

Documentation/driver-api

Start with DocBook/device-drivers.tmplConvert to several .rst files under driver-api/

Grab Documentation/hsi.txtMerge with driver-api/hsi.rstHSI is now documented in one place!

Page 57: Kernel Recipes 2016 - Kernel documentation: what we have and where it’s going

Documentation/driver-api

Start with DocBook/device-drivers.tmplConvert to several .rst files under driver-api/

Grab Documentation/hsi.txtMerge with driver-api/hsi.rstHSI is now documented in one place!

(This is just the beginning)

Page 58: Kernel Recipes 2016 - Kernel documentation: what we have and where it’s going

Coming in 4.9

Documentation/driver-api/Conversion of the device-drivers book(+ various text files)

Documentation/dev-tools/Coalesced tool documents in RST

PDF outputPainful, with LaTex

Page 59: Kernel Recipes 2016 - Kernel documentation: what we have and where it’s going

4.10?

Documentation/process/HOWTOCodingStyleSubmittingPatchesstable_kernel_rules.txtManagementStyledevelopment-process...

Page 60: Kernel Recipes 2016 - Kernel documentation: what we have and where it’s going

Future work

Convert other DocBook documentsEventually eliminate DocBook altogether

Rethink the kernel-doc utility20 years of Perl cruft!

Incorporate more plain-text documents

Bring some order to Documentation/

Page 61: Kernel Recipes 2016 - Kernel documentation: what we have and where it’s going

Future work

Convert other DocBook documentsEventually eliminate DocBook altogether

Rethink the kernel-doc utility20 years of Perl cruft!

Incorporate more plain-text documents

Bring some order to Documentation/

Create more, better documentation!

Page 62: Kernel Recipes 2016 - Kernel documentation: what we have and where it’s going

Questions / thoughts?

Page 63: Kernel Recipes 2016 - Kernel documentation: what we have and where it’s going

I've mentioned that the new toolchain is awesome, right?— Daniel Vetter