Skip to content

Publish level 2+3 patterns as a gitbook automatically #242

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Dec 13, 2020
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitbook.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
root : ./

structure:
readme: book/introduction.md
summary: book/toc.md
36 changes: 36 additions & 0 deletions .github/workflows/book.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Book ToC Generation

on:
pull_request:
push:
branches:
- "master"

jobs:
book-toc-generation:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.head_ref }}

- uses: actions/setup-ruby@v1
with:
ruby-version: '2.6'

- name: Install ruby dependencies
run: |
cd book/
gem install bundler
bundle install

- name: Generate ToC
run: |
cd book/
ruby generate_toc.rb

- name: Commit new ToC to book/toc.md
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Writing new ToC for the book
1 change: 1 addition & 0 deletions book/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Gemfile.lock
7 changes: 7 additions & 0 deletions book/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# frozen_string_literal: true

source "https://rubygems.org"

git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }

gem 'commonmarker'
44 changes: 44 additions & 0 deletions book/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# How to generate the InnerSource Patterns gitbook

Whenever changes to the [InnerSource Patterns][InnerSourcePatterns] GitHub repository are made, a new version of our InnerSource Patterns book is published at gitbook.com.

The files in the `./book` folder contain generator scripts and some extra content required to create our gitbook.

## Where is the book published?

The most up-to-date version of the book is available for readers/consumers at [innersourcecommons.gitbook.io/innersource-patterns/][book_production].

*NOTE:*
The final URL of the book has not been determined yet.

We also have a [Staging version][book_staging], used by the editors/producers of the book for testing purposes.

## Which patterns are published?

In the book we publish the patterns of maturity **Structured** (Level 2) or **Validated** (Level 3). For more on these maturity levels see the [Contributor Handbook](../meta/contributor-handbook.md).

## How does it work?

- `/.gitbook.yaml` - Holds basic configuration for the gitbook service. This never needs to be changed.
- `/book/toc.md` - An auto-generated table of contents (ToC) for the book i.e. a list of all pages and patterns that are part of the book. The ToC is what you see on the left-hand-side menu in gitbooks.
- `/book/generate_toc.rb` - Takes patterns of maturity **Structured** and **Validated**, extracts title and patlet, and injects this info into `/book/toc_template.md`. The output is written to `/book/toc.md`.
- `.github/workflows/book.yml` - A GitHub Action that triggers the execution of `/book/generate_toc.rb`.
- `/book/introduction.md` - The introduction to our book. This content is what the reader sees first when they open the book. The current content is based on [README.md](../README.md). We may need to modify this content even further, to address the readers of the book more specifically, rather than the readers of our GitHub repository.
- `/book/contribute-to-this-book.md` - Information about how to contribute to this book.

## Objectives of the book

These patterns are already publicly available in the [InnerSource Patterns][InnerSourcePatterns] GitHub repo. So why publish such a book at all?

We think there are a couple of good reasons to publish the InnerSource patterns as a gitbook:

* (consumers) have something that is “nicer” to read than things on GitHub
* (consumers) have stable URLs for patterns i.e. even if the files move in the folder structure in the repo, the URL of the pattern stay the same
* (consumers) export book as PDF and read on other devices
* (producers) a motivation for pattern authors (and all contributors) to level up patterns from 1-initial, as only 2-structured and 3-validated are published in the book
* (producers) a motivation for us to introduce more specific quality guidelines for level 2+3, so that we can be even more proud of the content in the book :)
* (producers) learn which patterns are most interesting for readers (e.g. through Google Analytics)

[InnerSourcePatterns]: https://github.com/InnerSourceCommons/InnerSourcePatterns
[book_production]: https://innersourcecommons.gitbook.io/innersource-patterns/
[book_staging]: https://innersourcecommons.gitbook.io/innersource-patterns-staging/v/book/
27 changes: 27 additions & 0 deletions book/contribute-to-this-book.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Contribute to this book

You want to help us make this book better? That is awesome!

The InnerSource Patterns book itself is an open source project, and welcomes any form of contribution. Nothing is too small!

If you have never made a contribution to an open source project before, know that the InnerSource Patterns community is group of friendly people and with that a safe place to try it out :)

## Before you get started

As the sources for the InnerSource Patterns and this book are kept in a repository on GitHub, you will need a user account there to make edits and suggestions to this book. If you don't have a user account at GitHub yet, head over to [github.com](https://github.com) and create one for free.

## Different ways to contribute

Here a few ways in which you can contribute:

1. fix spelling, formatting, or other glitches that you notice in this book
2. improve the content of an existing pattern (e.g. by adding a short description of how you are using a pattern as a _Known Instance_)
3. contribute a new pattern, describing how you have overcome InnerSource-related challenges in your organization

For (1) and (2) above you can simply hit the **Edit on GitHub** link that you see at the top of each page in the book. This will take you straight to the respective file in our GitHub repository, where you can suggest your changes.

For (3) you need to clone the [InnerSourcePatterns](https://github.com/InnerSourceCommons/InnerSourcePatterns) repository, and add a new file with your suggested pattern. When making such larger contributions to this book please review our [CONTRIBUTING.md](../CONTRIBUTING.md) and also our [Contributor Handbook](../meta/contributor-handbook.md).

## License of Contributions

The contents of this repository are licensed under [CC-BY-SA-4.0](../LICENSE.txt). By contributing to this repository, you grant us (and everyone else for that matter) the right to use your contribution in accordance with that license.
89 changes: 89 additions & 0 deletions book/generate_toc.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
require 'rubygems'
require 'bundler/setup'
Bundler.require(:default)

require 'pp'

# Extracts the value of a specific section from a markdown file
def extract_section(file, section_title)
markdown = open(file).readlines().join
doc = CommonMarker.render_doc(markdown)

title_found = false
section_nodes = []

# once the header in question is found, extract all the text nodes from the
# subsequent paragaph
doc.walk do |node|
if node.type == :header
node.each do |subnode|
if subnode.type == :text and subnode.string_content == section_title
title_found = true
end
end
elsif node.type == :paragraph && title_found == true
node.each do |subnode|
section_nodes += extract_text(subnode)
end
break # stop the recursion once the paragraph has been processed
end
end

section_content = section_nodes.join("")
return section_content
end

# extracts the pure text content from this CommonMarker node, and its children.
# returns an array of strings
def extract_text(node)
section_nodes = []
if node.type == :softbreak
section_nodes << " "
elsif node.type == :text
section_nodes << node.string_content
else
node.each do |subnode|
section_nodes += extract_text(subnode)
end
end
return section_nodes
end


def generate_patterns_overview(patterns)
pattern_overview = Hash.new()

patterns.each do |file|
title = extract_section(file, "Title")
patlet = extract_section(file, "Patlet")
pattern_overview[title] = {
:file => file,
:patlet => patlet
}
end

pattern_overview
end


# Main block

TOC_TEMPLATE_FILE = "./toc_template.md"
TOC_FILE = "./toc.md"

## Generate list of patterns and sort them by name
patterns = Dir["../patterns/2-structured/*.md","../patterns/2-structured/project-setup/*.md", "../patterns/3-validated/*.md"]
pattern_overview = generate_patterns_overview(patterns)
pattern_overview = pattern_overview.sort.to_h

toc_snippet = pattern_overview.map{|title, values| "* [#{title}](#{values[:file]}) - #{values[:patlet]}"}
toc_snippet = toc_snippet.join("\n")

## Inject the list of patterns into the ToC template
new_toc_content = open(TOC_TEMPLATE_FILE).readlines().join()
new_toc_content = new_toc_content.gsub(/<<PATTERS_HERE>>/,toc_snippet)

## Write the new ToC to file
File.write(TOC_FILE, new_toc_content)

puts "Written new ToC for book to #{TOC_FILE}"
Binary file added book/innersource-patterns-book-cover.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added book/innersource-program-mind-map.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
66 changes: 66 additions & 0 deletions book/introduction.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Introduction

<img src="./innersource-patterns-book-cover.jpg" title="InnerSource Patterns">

{% hint style="info" %}
This is an early release of the InnerSource Patterns book.
You may still find broken links, spelling mistakes, or other errors in this book.
Please help us to fix them to produce the best book possible :) Learn here how to [contribute to this book](../book/contribute-to-this-book.md).
{% endhint %}

Welcome to the **InnerSource Patterns book**.

This book contains InnerSource best practices codified in a specific format to make it easy to understand, evaluate, and reuse them. We call this reuse format a **pattern**.

These patterns have been collected by the [InnerSource Commons](http://innersourcecommons.org) community over many years. The most mature of these patterns have been published in this book.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By mature, are we referring to proven? If so, should we mention this to make sure people understand that these are tried and proven and not just some ideas?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have changed the pattern maturity levels in the meantime. We now have 3 levels (full details):

  • 1 initial
  • 2 structured
  • 3 validated

Patterns of level 2 or 3 are published in the book. So far we don't have any patterns in level 3 yet though :)


In this introduction we explain [what InnerSource is](#what-is-innersource), [what a pattern is](#what-are-innersource-patterns), and [how to use these patterns](#how-can-you-use-innersource-patterns) in your organization.

If you are using InnerSource in your company already and want to contribute your experiences to this book we would love to [welcome your contributions](../book/contribute-to-this-book.md)!

## What is InnerSource?

We define InnerSource as:

> The use of open source principles and practices for software development within the confines of a company.

InnerSource takes the lessons learned from developing open source software and applies them to the way companies develop software internally. As developers have become accustomed to working on world class open source software, there is a strong desire to bring those practices back inside the firewall and apply them to software that companies may be reluctant to release.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bring those practices back inside the firewall

Bringing them back implies that they were there previously. I'd argue that's seldomly if ever the case. Also, I'm not familiar with the term "inside the firewall".

Suggestion: "... there is a strong desire to apply those practices inside their organisations to software that they may be reluctant to or can't release as Open Source."

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got this text from https://innersourcecommons.org, section "What is InnerSource?" :)

I am happy to change it, but maybe we should change innersourcecommons.org as well then?


For companies building mostly closed source software, InnerSource can be a great tool to help break down silos, encourage internal collaboration, accelerate new engineer on-boarding, and identify opportunities to contribute software back to the open source world.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my experience (thus far), silos never quite go away - they are just made more "permeable". Not sure we should mention this here but I feel we need to be careful setting the right expectations.

Copy link
Member Author

@spier spier Dec 5, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above: I got this text from https://innersourcecommons.org, section "What is InnerSource?"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After reviewing all other comments, I noticed that this comment and the two comments below are all modifying text that I copied from somewhere else within the ISC.

In order to get the book released quickly I would therefore propose the following:

  • we resolve these 3 comments (i.e. leave the text as is)
  • get the book released

After that if you want to improve these descriptions, maybe you could open new PRs against the innersourcecommons.org or InnerSourcePatterns repo, and then we can port those changes into the book after that gets merged.

What do you think?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gruetter if you can give me the green light on the approach highlighted in my last comment above, then I could get the first version of the book released over the weekend. So if you have any time to review this, would be much appreciated.


## What are InnerSource Patterns?

Patterns are a way of describing a repeatable, proven solution to a problem with a context. They follow a simple form that helps people wanting to implement the solution to understand the constraints on the problem, the forces that must be balanced and the resulting context (the situation you are left with after the solution is applied).

In inner sourcing, patterns can provide a way for the InnerSource Commons participants to concisely share information with each other, improving the practice of inner sourcing. Each of the patterns are divided into Title, Problem Statement, Context, Forces, and Solutions as their main sections.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
In inner sourcing, patterns can provide a way for the InnerSource Commons participants to concisely share information with each other, improving the practice of inner sourcing. Each of the patterns are divided into Title, Problem Statement, Context, Forces, and Solutions as their main sections.
In inner sourcing, patterns can provide a way for the InnerSource Commons participants to concisely share information with each other, improving the practice of inner sourcing. Pattern descriptions are subdivided into the following sections: Title, Patlet, Problem Statement, Context, Forces, Solutions and Resulting Context.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This text comes from here: https://github.com/InnerSourceCommons/InnerSourcePatterns#what-are-innersource-patterns

But again, I am happy to change it :)


* [`What are patterns?` Youtube videos](http://bit.ly/innersource_patterns_videos) - Watch a set of 2-5 min youtube videos explaining InnerSource Patterns
* [Pattern Discussion Webinar](https://youtu.be/i-0IVhfRVFU) - We held a webinar 2017-03-16 to live-discuss a donut pattern (go to 24:30 for the discussion). This is an illustration of the review process we follow. Also see the [June 1, 2017 O'Reilly Webinar on InnerSource Patterns](http://www.oreilly.com/pub/e/3884).
* [Pattern Template](../meta/pattern-template.md) - View a skeleton inner source pattern to get an idea on what goes into a new pattern!
* [Introduction to InnerSource Patterns (2016 Fall Summit presentation)](https://drive.google.com/open?id=0B7_9iQb93uBQbnlkdHNuUGhpTXc) - *Tim Yao and Padma Sudarsan* (PDF). Detailed pattern background and examples -- Get a detailed understanding of why and how to interact with our patterns. Also see the [Introduction to InnerSource Patterns (2017 Fall Summit)](https://drive.google.com/open?id=0B7_9iQb93uBQWmYwMFpyaGh4OFU) *Tim Yao and Bob Hanmer* (PDF).

## How can you use InnerSource Patterns?

Patterns must be used in a thoughtful manner. They cannot be blindly applied. In most cases, you will need to adapt the given solution to your own situation; but the information given in the pattern, defining the context (immovable constraints) and forces (constraints that can be changed and balanced against each other), should help you do this. Note that you will also need to determine if there are additional constraints (company context and company forces) that apply to your particular company/organization that must be added to the pattern (as a kind of filter). These additional constraints may require additional solution steps to be applied.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Proposal: s/immovable/invariable or s/immovable/fixed or s/immovable/immutable

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that you will also need to determine if there are additional constraints (company context and company forces) that apply to your particular company/organization that must be added to the pattern

Not sure I grok this. How would a potential user add a constraint to the pattern? Do we rather mean: "... that must be considered before applying the pattern"?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


The pattern form is useful for describing proven patterns but it can also be used for *brainstorming solutions* where patterns are not yet established, since the form gives a structured way for thinking about a problem. You could also create a *donut pattern* (filling in the problem, context, forces and resulting context fields but leaving the solution blank) as a way of asking the InnerSource Commons community for help (to find a proven solution or to brainstorm things to try).

## How to Contribute?

Please refer to: [Contribute to this book](./contribute-to-this-book.md)

## Credits

This book is the result of many years of work from countless [Open Source Contributors](https://github.com/InnerSourceCommons/InnerSourcePatterns/graphs/contributors) from around the world. Their willingness to openly share the challenges that they faced in their companies, and how InnerSource has helped them address those challenges, make this book such a valuable resource for others on their InnerSource journey.

We want to specifically mention the InnerSource Patterns Working Group. They have nurtured the quality of the InnerSource Patterns and helped others to contribute. Lastly they also compiled a selection of available patterns into this book.

The title image of this book was created by [Sebastian Spier](https://spier.hu) and adapted from an image by [Tony Hisgett - Alhambra 6](https://www.flickr.com/photos/hisgett/29345405788/), available under [CC BY 2.0](https://creativecommons.org/licenses/by/2.0/).

**Thank you to all contributors! And happy InnerSource Day :)**

## Licensing

![Creative Commons License](https://i.creativecommons.org/l/by-sa/4.0/88x31.png)

InnerSourcePatterns by [InnerSourceCommons.org](http://innersourcecommons.org) is licensed under a [Creative Commons Attribution-ShareAlike 4.0 International](http://creativecommons.org/licenses/by-sa/4.0/) License.
Loading