How to copy code from librustdoc?


#1

Hey,

I’ve found a component in librustdoc that I would like to copy into my own project (licensed under Apache 2.0).

I am uncertain how to apply proper copyright attribution and indicate which license(s) are being used.

The following is an example license header in one of the source files:

// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

Scenarios

I choose to copy the code only under the terms of the Apache 2.0 license

These are roughly the restrictions that apply according to my understanding of it:

  • Keep the copyright notice
  • My project needs a copy of the source-project NOTICE (e.g. NOTICE-rust).
  • My project needs a copy of the complete Apache 2 license (e.g. LICENSE-APACHE).

The copied copyright header could look something like this:

// Copyright 2013 The Rust Project Developers.
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0>.

I choose to copy the code only under the terms of the MIT license

These are roughly the restrictions that apply according to my understanding of it:

  • Keep the copyright notice
  • My project needs a copy of the MIT license (e.g. LICENSE-MIT). This could also be included in the header.

The copied copyright header could look something like this:

// Copyright 2013 The Rust Project Developers.
// Licensed under the MIT license <LICENSE-MIT or http://opensource.org/licenses/MIT>.

Include wording in the headers that can be copied in verbatim

Both licenses require that the original copyright notice be included, and that the licensing terms be included. The wording in the existing headers doesn’t make it easy to distinguish between these, especially in the scenario where only one license is being applied.

We could have a header that makes it easier to copy the following things line by line:

  • Copyright attribution (e.g. Copyright 2013 The Rust Project Developers.)
  • MIT license
  • Apache 2.0 license

Something like the following:

// Copyright 2013 The Rust Project Developers.
// Licensed under the MIT license <LICENSE-MIT or http://opensource.org/licenses/MIT>.
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0>.
//
// See the COPYRIGHT file at the top-level directory of this distribution and at http://rust-lang.org/COPYRIGHT.

As for This file may not be copied, modified, or distributed ..., I’m not sure how to include it, but it would appear self-evident that the licensing terms apply for a granted license.

I am also unsure of how to include ... at your option. This is wording that again makes it unclear which license is actually being applied.

Update COPYRIGHT with instructions for how to do attribution

Even if the existing copyright headers are left intact, I would need instructions for how to:

  • Provide attribution under the terms of one of the licenses.
  • Provide attribution under the terms of both licenses.