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

Directive to include code without license header #20

Merged
merged 4 commits into from
May 21, 2020

Conversation

daniellimws
Copy link
Contributor

This is implemented in the no-license directive, which has the exact same usage and options as literalinclude. Only difference is the lines options is set to start after the license header and to end at the last line of the file.

The end of the license header is detected by searching for the line that contains the SPDX identifier. Therefore this directive assumes that the license header contains the SPDX identifier.

I’m not sure how to name it :P. no-license sounds weird while no-license-include is so long. Running out of ideas.

Resolve chipsalliance/f4pga-v2x#47

Signed-off-by: Daniel Lim Wee Soong weesoong.lim@gmail.com

@mithro
Copy link
Member

mithro commented Apr 25, 2020

Could you add a demo / test in the documentation somewhere?

@daniellimws
Copy link
Contributor Author

Currently, there is no difference in using literalinclude or no-license in the examples because there is no license header. The effect can be seen when #19 is merged.

@daniellimws
Copy link
Contributor Author

When we merge this, we need to arrange the commits so that the patch for -compat-int comes after this so that we can use this directive without breaking the build. Alternatively, temporarily remove that option until yosys in conda is upgraded to a newer version?

rel_filename, filename = self.env.relfn2path(self.arguments[0])
code = open(rel_filename, 'r').read().strip().split('\n')
first_line = next(
(idx + 3 for idx, line in enumerate(code) if 'SPDX' in line), 1)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Currently, this assumes that the license header is in the C-style multiline comment format, with a newline after the comment, hence the idx + 3. For example

/*
 * Copyright (C) 2020  The SymbiFlow Authors.
 *
 * Use of this source code is governed by a ISC-style
 * license that can be found in the LICENSE file or at
 * https://opensource.org/licenses/ISC
 *
 * SPDX-License-Identifier:	ISC
 */

In the python files there will not be an extra line ending the comment (the */ line), and might not have a newline after the header (for example I see this in chipsalliance/fasm@5d25dc7). Since this is the verilog-diagrams extension, should we for now just narrow our use case to our verilog code which supposedly fits these assumptions, and not worry about the other languages (for example python)?

Copy link
Member

Choose a reason for hiding this comment

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

Verilog supports both /* and // style comments IIRC, so we should at least support them.

@mithro
Copy link
Member

mithro commented Apr 26, 2020

FYI - You need to rebase this.

@daniellimws
Copy link
Contributor Author

Rebased and changed to determine starting line based on type of comment used

@mithro
Copy link
Member

mithro commented May 21, 2020

Could you rebase this, then I'll merge?

This is implemented in the `no-license` directive, which has the
exact same usage and options as `literalinclude`. Only difference
is the `lines` options is set to start after the license header
and to end at the last line of the file.

The end of the license header is detected by searching for the
line that contains the SPDX identifier. Therefore this directive
assumes that the license header contains the SPDX identifier.

Signed-off-by: Daniel Lim Wee Soong <weesoong.lim@gmail.com>
Signed-off-by: Daniel Lim Wee Soong <weesoong.lim@gmail.com>
- The link from README.md to the docs is broken.
- Add a link from the docs to the GitHub repo.

Signed-off-by: Daniel Lim Wee Soong <weesoong.lim@gmail.com>
Signed-off-by: Daniel Lim Wee Soong <weesoong.lim@gmail.com>
@daniellimws
Copy link
Contributor Author

Ok done.

@mithro mithro merged commit e4cbcd3 into SymbiFlow:master May 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Figure out how to skip copyright header in verilog output in rendered Sphinx docs
2 participants