Skip to content
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

Add docs/ folder and an intro tutorial #958

Merged
merged 5 commits into from
Oct 12, 2022
Merged

Add docs/ folder and an intro tutorial #958

merged 5 commits into from
Oct 12, 2022

Conversation

abhinav
Copy link
Collaborator

@abhinav abhinav commented Oct 11, 2022

This adds a new docs/ folder to the repository.
We'll put non-API-reference documentation in this folder.

To begin with, this folder contains the following documentation:

  • docs/get-started/README holds an introduction to Fx tutorial
  • docs/CONTRIBUTING holds guidance for adding new documentation
    (please read before adding documentation)

In the interest of keeping the documentation up-to-date and valid,
we make use of mdox to:

  • reformat Markdown to the same format
  • verify that code samples are up-to-date
  • all links in the documentation are valid

Further, to ensure that all the code samples are runnable,
this includes tests for all example code.
Testing the example code is a bit complex because we
need to treat it like an application "from outside"
so all tests rely on TestMain-style hijacking to run the programs.


Rendered documentation:

@codecov
Copy link

codecov bot commented Oct 11, 2022

Codecov Report

Merging #958 (88ba16b) into master (22fe86d) will decrease coverage by 0.11%.
The diff coverage is 97.02%.

@@            Coverage Diff             @@
##           master     #958      +/-   ##
==========================================
- Coverage   98.73%   98.62%   -0.12%     
==========================================
  Files          32       38       +6     
  Lines        1428     1529     +101     
==========================================
+ Hits         1410     1508      +98     
- Misses         13       15       +2     
- Partials        5        6       +1     
Impacted Files Coverage Δ
docs/internal/exectest/cmd.go 72.72% <72.72%> (ø)
docs/internal/apptest/run.go 100.00% <100.00%> (ø)
docs/internal/exectest/output.go 100.00% <100.00%> (ø)
docs/internal/httptest/http.go 100.00% <100.00%> (ø)
docs/internal/iotest/read.go 100.00% <100.00%> (ø)
docs/internal/test/fake.go 100.00% <100.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@abhinav abhinav force-pushed the abg/tutorial branch 2 times, most recently from 5586d78 to bf33fa2 Compare October 11, 2022 17:17
This adds a new docs/ folder to the Fx repository.
This is where non-API-reference documentation will reside.

To set things up, this adds a docs/CONTRIBUTING.md
with guidance on how to contribute to the Fx documentation.

It includes tooling to ensure that code snippets
inside documentation remain up to date.
To do that, this relies on two tools:

- mdox does the bulk of the heavy lifting here
- the region shell script helps pick out named snippets of code
  from a flie
@abhinav abhinav force-pushed the abg/tutorial branch 2 times, most recently from f10683f to 0a63915 Compare October 11, 2022 17:55
@abhinav
Copy link
Collaborator Author

abhinav commented Oct 11, 2022

Looks like we can't have the doc tests run on Windows.
It doesn't support sending SIGINT from within the process.
I'll adjust the jobs to run docs test only on Linux.

@abhinav
Copy link
Collaborator Author

abhinav commented Oct 11, 2022

Note that the only failure here is that parts of the code added in the patch are not covered.
Those lines that are missing are difficult to get coverage data out of because they run a subprocess.
Other than that, this change is good to go.

This adds a "Getting started with Fx" tutorial.
The tutorial is intended to be a simple step-by-step with minimal
explanations that a user can follow along to.

At the end of the tutorial, they'll have encountered:

- basic dependency injection
- named values
- value groups
This rewords the introduction in the readme
to better state the benefits of using Fx,
and links to the get-started tutorial to help users get started.

Part of this is to add the root README to
the list of files processed by mdox,
as a result of which some of the links are also rewritten.
(mdox prefers inline links, not reference style links,
and there's no way to change that right now.)
This adds tests for all get-started code samples.

Since can't get coverage for these tests
because they rely on os/exec to create subprocesses,
also exclude these tests from codecov's coverage tracking.
The example test is flaky because `go ListenAndServe()`
is not always ready to accept connections by the time
we get to making the request.

To fix this, start a listener explicitly in a blocking manner,
and run the Serve goroutine separately.
@abhinav abhinav merged commit 43f516d into master Oct 12, 2022
@abhinav abhinav deleted the abg/tutorial branch October 12, 2022 02:21
@abhinav abhinav mentioned this pull request Oct 12, 2022
abhinav added a commit that referenced this pull request Oct 12, 2022
This migrates docs added in #958 into a GitHub Pages website
powered by Vuepress (same as https://cadenceworkflow.io/).

Besides the boilerplate, this carries the content over almost as-is.

One change we've made here is to split the many sections of the getting started
tutorial into different pages.
This helps keep the length of the document manageable,
and makes the transition between each step more obvious.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants