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

feat(forge): doc #2701

Merged
merged 76 commits into from
Jan 16, 2023
Merged

feat(forge): doc #2701

merged 76 commits into from
Jan 16, 2023

Conversation

rkrasiuk
Copy link
Collaborator

@rkrasiuk rkrasiuk commented Aug 10, 2022

Motivation

Implementation of forge doc described in #1675

Solution

The forge doc command parses the source contracts and generates markdown files under <root>/docs. These files can be served by running forge doc --serve.

See README for more details on the architecture of the doc module

@rkrasiuk rkrasiuk added T-feature Type: feature C-forge Command: forge labels Aug 10, 2022
@rkrasiuk rkrasiuk marked this pull request as draft August 10, 2022 18:53
cli/src/cmd/forge/doc.rs Outdated Show resolved Hide resolved
Copy link
Member

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

+1 on making doc a crate, let's try to move as much of the logic there,

ideally, there should be some kind of Builder, or function that accepts a config and will handle it from there.

@onbjerg onbjerg linked an issue Aug 11, 2022 that may be closed by this pull request
4 tasks
@rkrasiuk rkrasiuk added the Cmd-forge-doc Command: forge doc label Aug 11, 2022
impl<'a> DocFormat for DocOutput<'a> {
fn doc(&self) -> String {
match self {
Self::H1(val) => format!("# {val}"),
Copy link
Contributor

Choose a reason for hiding this comment

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

is it possible to add pandoc attribute headers here too?
see pandoc docs about attr headers

Also, idk if you may find this useful reference https://github.com/sambacha/go-natspec , would like to see forge doc as a separate binary if possible (if its a separate crate this should be the case correct?)

Copy link
Member

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

only did a high level review, just because this is quite huge, but it's very readable and you can understand how this is supposed to work just by reading this.

smol nits, otherwise lgtm

config/src/doc.rs Outdated Show resolved Hide resolved
doc/src/builder.rs Show resolved Hide resolved
doc/src/preprocessor/contract_inheritance.rs Outdated Show resolved Hide resolved
doc/src/preprocessor/git_source.rs Outdated Show resolved Hide resolved
@emo-eth
Copy link
Contributor

emo-eth commented Jan 11, 2023

Running on the Seaport 1.2 branch results in a rather unhelpful error:

❯ forge doc --serve
Error: 
Failed to parse source: unknown comment tag: 

@sambacha
Copy link
Contributor

https://github.com/foundry-rs/foundry/blob/7c135cd969092710ad53d2532c3113a9a4517344/doc/src/writer/markdown.rs#L21:5

Only FencedCodeBlock, as there are two different kinds of Code Blocks: Fenced and Indentation based. I don't think you want to support Indentation-based code blocks for generated output.

Can we add reference links for each natspec section back to the relevant source lineos?

Copy link
Member

@gakonst gakonst left a comment

Choose a reason for hiding this comment

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

Absolutely incredible. Would prefer if we used Axum instead of Warp. Love the Preprocessor keeping things clean.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-forge Command: forge Cmd-forge-doc Command: forge doc T-feature Type: feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat: forge doc
8 participants