mirror of https://github.com/icedland/iced.git
Update rust deprec writer to not deprecate the enum if some feature is passed in
This commit is contained in:
parent
acbf7eb974
commit
5a3dba7c12
|
@ -12,29 +12,35 @@ namespace Generator.Documentation.Rust {
|
|||
public RustDeprecatedWriter(IdentifierConverter idConverter) =>
|
||||
this.idConverter = idConverter;
|
||||
|
||||
public override void WriteDeprecated(FileWriter writer, EnumValue value) {
|
||||
public override void WriteDeprecated(FileWriter writer, EnumValue value) =>
|
||||
WriteDeprecated(writer, value, null);
|
||||
|
||||
public void WriteDeprecated(FileWriter writer, EnumValue value, string? notDeprecFeature) {
|
||||
if (value.DeprecatedInfo.IsDeprecated) {
|
||||
if (value.DeprecatedInfo.NewName is not null) {
|
||||
var newValue = value.DeclaringType[value.DeprecatedInfo.NewName];
|
||||
WriteDeprecated(writer, value.DeprecatedInfo.VersionStr, newValue.Name(idConverter), value.DeprecatedInfo.Description);
|
||||
WriteDeprecated(writer, value.DeprecatedInfo.VersionStr, newValue.Name(idConverter), value.DeprecatedInfo.Description, notDeprecFeature);
|
||||
}
|
||||
else
|
||||
WriteDeprecated(writer, value.DeprecatedInfo.VersionStr, null, value.DeprecatedInfo.Description);
|
||||
WriteDeprecated(writer, value.DeprecatedInfo.VersionStr, null, value.DeprecatedInfo.Description, notDeprecFeature);
|
||||
}
|
||||
}
|
||||
|
||||
public override void WriteDeprecated(FileWriter writer, Constant value) {
|
||||
public override void WriteDeprecated(FileWriter writer, Constant value) =>
|
||||
WriteDeprecated(writer, value, null);
|
||||
|
||||
public void WriteDeprecated(FileWriter writer, Constant value, string? notDeprecFeature) {
|
||||
if (value.DeprecatedInfo.IsDeprecated) {
|
||||
if (value.DeprecatedInfo.NewName is not null) {
|
||||
var newValue = value.DeclaringType[value.DeprecatedInfo.NewName];
|
||||
WriteDeprecated(writer, value.DeprecatedInfo.VersionStr, newValue.Name(idConverter), value.DeprecatedInfo.Description);
|
||||
WriteDeprecated(writer, value.DeprecatedInfo.VersionStr, newValue.Name(idConverter), value.DeprecatedInfo.Description, notDeprecFeature);
|
||||
}
|
||||
else
|
||||
WriteDeprecated(writer, value.DeprecatedInfo.VersionStr, null, value.DeprecatedInfo.Description);
|
||||
WriteDeprecated(writer, value.DeprecatedInfo.VersionStr, null, value.DeprecatedInfo.Description, notDeprecFeature);
|
||||
}
|
||||
}
|
||||
|
||||
static void WriteDeprecated(FileWriter writer, string version, string? newName, string? description) {
|
||||
static void WriteDeprecated(FileWriter writer, string version, string? newName, string? description, string? notDeprecFeature) {
|
||||
string extra;
|
||||
if (description is not null)
|
||||
extra = description;
|
||||
|
@ -42,7 +48,11 @@ namespace Generator.Documentation.Rust {
|
|||
extra = $"Use {newName} instead";
|
||||
else
|
||||
extra = "Don't use it!";
|
||||
writer.WriteLine($"#[deprecated(since = \"{version}\", note = \"{extra}\")]");
|
||||
var deprecatedAttr = $"deprecated(since = \"{version}\", note = \"{extra}\")";
|
||||
if (notDeprecFeature is not null)
|
||||
writer.WriteLine($"#[cfg_attr(not(feature = \"{notDeprecFeature}\"), {deprecatedAttr})]");
|
||||
else
|
||||
writer.WriteLine($"#[{deprecatedAttr}]");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace Generator.Enums.Rust {
|
|||
readonly IdentifierConverter idConverter;
|
||||
readonly Dictionary<TypeId, PartialEnumFileInfo?> toPartialFileInfo;
|
||||
readonly RustDocCommentWriter docWriter;
|
||||
readonly DeprecatedWriter deprecatedWriter;
|
||||
readonly RustDeprecatedWriter deprecatedWriter;
|
||||
readonly RustConstantsWriter constantsWriter;
|
||||
|
||||
sealed class PartialEnumFileInfo {
|
||||
|
|
Loading…
Reference in New Issue